2020-12-27 09:05:24 +08:00
|
|
|
|
|
|
|
|
|
|
|
## 8. Index Service
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#### 8.1 Overview
|
|
|
|
|
2021-01-04 14:16:43 +08:00
|
|
|
<img src="./figs/index_service.jpeg" width=700>
|
2020-12-27 09:05:24 +08:00
|
|
|
|
|
|
|
#### 8.2 API
|
|
|
|
|
2020-12-29 18:02:44 +08:00
|
|
|
```go
|
|
|
|
type Client interface {
|
|
|
|
BuildIndex(req BuildIndexRequest) (BuildIndexResponse, error)
|
2021-01-12 18:03:24 +08:00
|
|
|
GetIndexStates(req IndexStatesRequest) (IndexStatesResponse, error)
|
|
|
|
GetIndexFilePaths(req IndexFilePathRequest) (IndexFilePathsResponse, error)
|
2020-12-29 18:02:44 +08:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
* *BuildIndex*
|
|
|
|
|
|
|
|
```go
|
|
|
|
type BuildIndexRequest struct {
|
|
|
|
DataPaths []string
|
|
|
|
TypeParams map[string]string
|
|
|
|
IndexParams map[string]string
|
|
|
|
}
|
|
|
|
|
|
|
|
type BuildIndexResponse struct {
|
|
|
|
IndexID UniqueID
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-01-12 18:03:24 +08:00
|
|
|
* *GetIndexStates*
|
2020-12-29 18:02:44 +08:00
|
|
|
|
|
|
|
```go
|
2021-01-12 18:03:24 +08:00
|
|
|
type IndexStatesRequest struct {
|
|
|
|
IndexID UniqueID
|
|
|
|
}
|
|
|
|
|
|
|
|
enum IndexState {
|
2020-12-27 09:05:24 +08:00
|
|
|
NONE = 0;
|
|
|
|
UNISSUED = 1;
|
|
|
|
INPROGRESS = 2;
|
|
|
|
FINISHED = 3;
|
|
|
|
}
|
|
|
|
|
2021-01-12 18:03:24 +08:00
|
|
|
type IndexStatesResponse struct {
|
2020-12-27 09:05:24 +08:00
|
|
|
ID UniqueID
|
2021-01-12 18:03:24 +08:00
|
|
|
State IndexState
|
2020-12-27 09:05:24 +08:00
|
|
|
EnqueueTime time.Time
|
|
|
|
ScheduleTime time.Time
|
|
|
|
BuildCompleteTime time.Time
|
|
|
|
}
|
2020-12-29 18:02:44 +08:00
|
|
|
```
|
2020-12-27 09:05:24 +08:00
|
|
|
|
|
|
|
|
2020-12-29 18:02:44 +08:00
|
|
|
|
|
|
|
* *GetIndexFilePaths*
|
|
|
|
|
|
|
|
```go
|
2021-01-12 18:03:24 +08:00
|
|
|
type IndexFilePathRequest struct {
|
|
|
|
IndexID UniqueID
|
|
|
|
}
|
|
|
|
|
|
|
|
type IndexFilePathsResponse struct {
|
2020-12-29 18:02:44 +08:00
|
|
|
FilePaths []string
|
2020-12-27 09:05:24 +08:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2021-01-11 18:35:54 +08:00
|
|
|
|
|
|
|
|
|
|
|
#### 8.3 Index Node
|
|
|
|
|
|
|
|
```go
|
|
|
|
type IndexNode interface {
|
|
|
|
Start() error
|
|
|
|
Close() error
|
|
|
|
|
2021-01-12 18:03:24 +08:00
|
|
|
// SetTimeTickChannel(channelID string) error
|
2021-01-11 18:35:54 +08:00
|
|
|
SetStatsChannel(channelID string) error
|
|
|
|
|
|
|
|
BuildIndex(req BuildIndexRequest) (BuildIndexResponse, error)
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|