2020-12-27 01:05:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
## 8. Index Service
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#### 8.1 Overview
|
|
|
|
|
2021-01-04 06:16:43 +00:00
|
|
|
<img src="./figs/index_service.jpeg" width=700>
|
2020-12-27 01:05:24 +00:00
|
|
|
|
2021-01-13 03:08:03 +00:00
|
|
|
#### 8.2 Index Service Interface
|
2020-12-27 01:05:24 +00:00
|
|
|
|
2020-12-29 10:02:44 +00:00
|
|
|
```go
|
2021-01-13 03:08:03 +00:00
|
|
|
type IndexService interface {
|
|
|
|
Service
|
|
|
|
RegisterNode(req RegisterNodeRequest) (RegisterNodeResponse, error)
|
2020-12-29 10:02:44 +00:00
|
|
|
BuildIndex(req BuildIndexRequest) (BuildIndexResponse, error)
|
2021-01-12 10:03:24 +00:00
|
|
|
GetIndexStates(req IndexStatesRequest) (IndexStatesResponse, error)
|
|
|
|
GetIndexFilePaths(req IndexFilePathRequest) (IndexFilePathsResponse, error)
|
2020-12-29 10:02:44 +00:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-01-13 03:08:03 +00:00
|
|
|
* *RegisterNode*
|
|
|
|
|
|
|
|
```go
|
|
|
|
type RegisterNodeRequest struct {
|
2021-01-15 06:38:36 +00:00
|
|
|
MsgBase
|
2021-01-13 03:08:03 +00:00
|
|
|
Address string
|
|
|
|
Port int64
|
|
|
|
}
|
|
|
|
|
|
|
|
type RegisterNodeResponse struct {
|
|
|
|
//InitParams
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2020-12-29 10:02:44 +00:00
|
|
|
* *BuildIndex*
|
|
|
|
|
|
|
|
```go
|
|
|
|
type BuildIndexRequest struct {
|
|
|
|
DataPaths []string
|
|
|
|
TypeParams map[string]string
|
|
|
|
IndexParams map[string]string
|
|
|
|
}
|
|
|
|
|
|
|
|
type BuildIndexResponse struct {
|
|
|
|
IndexID UniqueID
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2021-01-12 10:03:24 +00:00
|
|
|
* *GetIndexStates*
|
2020-12-29 10:02:44 +00:00
|
|
|
|
|
|
|
```go
|
2021-01-12 10:03:24 +00:00
|
|
|
type IndexStatesRequest struct {
|
|
|
|
IndexID UniqueID
|
|
|
|
}
|
|
|
|
|
|
|
|
enum IndexState {
|
2020-12-27 01:05:24 +00:00
|
|
|
NONE = 0;
|
|
|
|
UNISSUED = 1;
|
|
|
|
INPROGRESS = 2;
|
|
|
|
FINISHED = 3;
|
|
|
|
}
|
|
|
|
|
2021-01-12 10:03:24 +00:00
|
|
|
type IndexStatesResponse struct {
|
2020-12-27 01:05:24 +00:00
|
|
|
ID UniqueID
|
2021-01-12 10:03:24 +00:00
|
|
|
State IndexState
|
2021-01-13 03:08:03 +00:00
|
|
|
//EnqueueTime time.Time
|
|
|
|
//ScheduleTime time.Time
|
|
|
|
//BuildCompleteTime time.Time
|
2020-12-27 01:05:24 +00:00
|
|
|
}
|
2020-12-29 10:02:44 +00:00
|
|
|
```
|
2020-12-27 01:05:24 +00:00
|
|
|
|
2020-12-29 10:02:44 +00:00
|
|
|
* *GetIndexFilePaths*
|
|
|
|
|
|
|
|
```go
|
2021-01-12 10:03:24 +00:00
|
|
|
type IndexFilePathRequest struct {
|
|
|
|
IndexID UniqueID
|
|
|
|
}
|
|
|
|
|
|
|
|
type IndexFilePathsResponse struct {
|
2020-12-29 10:02:44 +00:00
|
|
|
FilePaths []string
|
2020-12-27 01:05:24 +00:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2021-01-11 10:35:54 +00:00
|
|
|
|
|
|
|
|
2021-01-13 03:08:03 +00:00
|
|
|
#### 8.3 Index Node Interface
|
2021-01-11 10:35:54 +00:00
|
|
|
|
|
|
|
```go
|
|
|
|
type IndexNode interface {
|
2021-01-13 03:08:03 +00:00
|
|
|
Service
|
2021-01-14 12:30:27 +00:00
|
|
|
// SetTimeTickChannel(channelName string) error
|
|
|
|
// SetStatsChannel(channelName string) error
|
2021-01-11 10:35:54 +00:00
|
|
|
|
|
|
|
BuildIndex(req BuildIndexRequest) (BuildIndexResponse, error)
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|