update: add write mapping,setting info msg, go module name
This commit is contained in:
parent
887f450cf8
commit
ff7aa194aa
2
go.mod
2
go.mod
@ -1,4 +1,4 @@
|
|||||||
module esgo2dump
|
module github.com/loveuer/esgo2dump
|
||||||
|
|
||||||
go 1.18
|
go 1.18
|
||||||
|
|
||||||
|
@ -2,7 +2,8 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"esgo2dump/internal/opt"
|
|
||||||
|
"github.com/loveuer/esgo2dump/internal/opt"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -4,16 +4,17 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"esgo2dump/internal/interfaces"
|
|
||||||
"esgo2dump/internal/opt"
|
|
||||||
"esgo2dump/internal/xes"
|
|
||||||
"esgo2dump/internal/xfile"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
"github.com/spf13/cobra"
|
|
||||||
"io"
|
"io"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
|
"github.com/loveuer/esgo2dump/internal/interfaces"
|
||||||
|
"github.com/loveuer/esgo2dump/internal/opt"
|
||||||
|
"github.com/loveuer/esgo2dump/internal/xes"
|
||||||
|
"github.com/loveuer/esgo2dump/internal/xfile"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
func run(cmd *cobra.Command, args []string) error {
|
func run(cmd *cobra.Command, args []string) error {
|
||||||
@ -55,14 +56,26 @@ func run(cmd *cobra.Command, args []string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return ioo.WriteMapping(cmd.Context(), mapping)
|
if err = ioo.WriteMapping(cmd.Context(), mapping); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
logrus.Info("Dump: write mapping succeed!!!")
|
||||||
|
|
||||||
|
return nil
|
||||||
case "setting":
|
case "setting":
|
||||||
var setting map[string]any
|
var setting map[string]any
|
||||||
if setting, err = ioi.ReadSetting(cmd.Context()); err != nil {
|
if setting, err = ioi.ReadSetting(cmd.Context()); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return ioo.WriteSetting(cmd.Context(), setting)
|
if err = ioo.WriteSetting(cmd.Context(), setting); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
logrus.Info("Dump: write setting succeed!!!")
|
||||||
|
|
||||||
|
return nil
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("unknown type=%s", f_type)
|
return fmt.Errorf("unknown type=%s", f_type)
|
||||||
}
|
}
|
||||||
@ -98,7 +111,6 @@ func executeData(ctx context.Context, input, output interfaces.DumpIO) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
logrus.Infof("Dump: %d docs succeed!!!", succeed)
|
logrus.Infof("Dump: %d docs succeed!!!", succeed)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,19 +5,20 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"esgo2dump/internal/interfaces"
|
|
||||||
"esgo2dump/internal/opt"
|
|
||||||
"esgo2dump/internal/util"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
elastic "github.com/elastic/go-elasticsearch/v7"
|
|
||||||
"github.com/elastic/go-elasticsearch/v7/esapi"
|
|
||||||
"github.com/elastic/go-elasticsearch/v7/esutil"
|
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
elastic "github.com/elastic/go-elasticsearch/v7"
|
||||||
|
"github.com/elastic/go-elasticsearch/v7/esapi"
|
||||||
|
"github.com/elastic/go-elasticsearch/v7/esutil"
|
||||||
|
"github.com/loveuer/esgo2dump/internal/interfaces"
|
||||||
|
"github.com/loveuer/esgo2dump/internal/opt"
|
||||||
|
"github.com/loveuer/esgo2dump/internal/util"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewClient(url *url.URL, iot interfaces.IO, qm map[string]any) (interfaces.DumpIO, error) {
|
func NewClient(url *url.URL, iot interfaces.IO, qm map[string]any) (interfaces.DumpIO, error) {
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
package xes
|
package xes
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"esgo2dump/internal/util"
|
|
||||||
elastic "github.com/elastic/go-elasticsearch/v7"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
elastic "github.com/elastic/go-elasticsearch/v7"
|
||||||
|
"github.com/loveuer/esgo2dump/internal/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestGetESMapping(t *testing.T) {
|
func TestGetESMapping(t *testing.T) {
|
||||||
|
@ -4,10 +4,11 @@ import (
|
|||||||
"bufio"
|
"bufio"
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"esgo2dump/internal/interfaces"
|
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
|
"github.com/loveuer/esgo2dump/internal/interfaces"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
type client struct {
|
type client struct {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user