feat: 🎉 完成基本功能
This commit is contained in:
19
internal/interfaces/dumpio.go
Normal file
19
internal/interfaces/dumpio.go
Normal file
@ -0,0 +1,19 @@
|
||||
package interfaces
|
||||
|
||||
import "context"
|
||||
|
||||
type DumpIO interface {
|
||||
ReadData(context.Context, int) ([]*ESSource, error)
|
||||
WriteData(ctx context.Context, docs []*ESSource) (int, error)
|
||||
|
||||
ReadMapping(context.Context) (map[string]any, error)
|
||||
WriteMapping(context.Context, map[string]any) error
|
||||
|
||||
ReadSetting(ctx context.Context) (map[string]any, error)
|
||||
WriteSetting(context.Context, map[string]any) error
|
||||
|
||||
Close() error
|
||||
|
||||
IOType() IO
|
||||
IsFile() bool
|
||||
}
|
27
internal/interfaces/enum.go
Normal file
27
internal/interfaces/enum.go
Normal file
@ -0,0 +1,27 @@
|
||||
package interfaces
|
||||
|
||||
type IO int64
|
||||
|
||||
const (
|
||||
IOInput IO = iota
|
||||
IOOutput
|
||||
)
|
||||
|
||||
func (io IO) Code() string {
|
||||
switch io {
|
||||
case IOInput:
|
||||
return "input"
|
||||
case IOOutput:
|
||||
return "output"
|
||||
default:
|
||||
return "unknown"
|
||||
}
|
||||
}
|
||||
|
||||
type DataType int64
|
||||
|
||||
const (
|
||||
DataTypeData DataType = iota
|
||||
DataTypeMapping
|
||||
DataTypeSetting
|
||||
)
|
33
internal/interfaces/source.go
Normal file
33
internal/interfaces/source.go
Normal file
@ -0,0 +1,33 @@
|
||||
package interfaces
|
||||
|
||||
type ESSource struct {
|
||||
DocId string `json:"_id"`
|
||||
Index string `json:"_index"`
|
||||
Content map[string]any `json:"_source"`
|
||||
}
|
||||
|
||||
type ESResponse struct {
|
||||
ScrollId string `json:"_scroll_id"`
|
||||
Took int `json:"took"`
|
||||
TimedOut bool `json:"timed_out"`
|
||||
Shards struct {
|
||||
Total int `json:"total"`
|
||||
Successful int `json:"successful"`
|
||||
Skipped int `json:"skipped"`
|
||||
Failed int `json:"failed"`
|
||||
} `json:"_shards"`
|
||||
Hits struct {
|
||||
Total struct {
|
||||
Value int `json:"value"`
|
||||
Relation string `json:"relation"`
|
||||
} `json:"total"`
|
||||
MaxScore float64 `json:"max_score"`
|
||||
Hits []*ESSource `json:"hits"`
|
||||
} `json:"hits"`
|
||||
}
|
||||
|
||||
type ESMapping map[string]struct {
|
||||
Mappings struct {
|
||||
Properties map[string]any `json:"properties"`
|
||||
} `json:"mappings"`
|
||||
}
|
Reference in New Issue
Block a user