refactor: project code arch; feat: cancel operation anytime
This commit is contained in:
45
pkg/model/es.go
Normal file
45
pkg/model/es.go
Normal file
@ -0,0 +1,45 @@
|
||||
package model
|
||||
|
||||
type ESSource[T any] struct {
|
||||
DocId string `json:"_id"`
|
||||
Index string `json:"_index"`
|
||||
Content T `json:"_source"`
|
||||
Sort []any `json:"sort"`
|
||||
}
|
||||
|
||||
type ESResponseV6[T any] 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 int `json:"total"`
|
||||
MaxScore float64 `json:"max_score"`
|
||||
Hits []*ESSource[T] `json:"hits"`
|
||||
} `json:"hits"`
|
||||
}
|
||||
|
||||
type ESResponseV7[T any] 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[T] `json:"hits"`
|
||||
} `json:"hits"`
|
||||
}
|
19
pkg/model/io.go
Normal file
19
pkg/model/io.go
Normal file
@ -0,0 +1,19 @@
|
||||
package model
|
||||
|
||||
import "context"
|
||||
|
||||
type IOType string
|
||||
|
||||
const (
|
||||
Input IOType = "input"
|
||||
Output IOType = "output"
|
||||
)
|
||||
|
||||
type IO[T any] interface {
|
||||
ReadData(ctx context.Context, limit int, query map[string]any, fields []string, sort []string) ([]T, error)
|
||||
WriteData(ctx context.Context, items []T) (int, error)
|
||||
ReadMapping(ctx context.Context) (map[string]any, error)
|
||||
WriteMapping(ctx context.Context, mapping map[string]any) error
|
||||
ReadSetting(ctx context.Context) (map[string]any, error)
|
||||
WriteSetting(ctx context.Context, setting map[string]any) error
|
||||
}
|
Reference in New Issue
Block a user