cluster

package
v0.0.0-...-6f23c6b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 25, 2022 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ManagerNode = 1
	DataNode    = 2
	SearchNode  = 3
)
View Source
const (
	LeaderSharding   = 1
	FollowerSharding = 2
)

Variables

This section is empty.

Functions

func Index

func Index(conf *config.Config)

func RpcCall

func RpcCall(host string, method string, request interface{}, response interface{}) error

RpcCall RPC方法必须满足Go语言的RPC规则:方法只能有两个可序列化的参数,其中第二个参数是指针类型,并且返回一个error类型,同时必须是公开的方法

Types

type Cluster

type Cluster struct {
	ShardingNum  int //分片数
	ReplicateNum int //数据备份数

	SearchNodeCorpus []Node
	DataNodeCorpus   map[string]Node
}

func NewCluster

func NewCluster(shard, replicate int) *Cluster

func (*Cluster) Add

func (c *Cluster) Add(node Node) error

func (*Cluster) RouteSearchNode

func (c *Cluster) RouteSearchNode() Node

func (*Cluster) RouteShardingNode

func (c *Cluster) RouteShardingNode(flag int) (Sharding2Node, error)

type DataServer

type DataServer struct {
	// contains filtered or unexported fields
}

func NewDataServer

func NewDataServer(config *config.Config) *DataServer

func (*DataServer) Add

func (s *DataServer) Add(doc index.Document)

Add 实时更新

func (*DataServer) Del

func (s *DataServer) Del(doc index.Document)

Del 实时删除

func (*DataServer) Run

func (s *DataServer) Run()

func (*DataServer) Search

func (s *DataServer) Search(request SearchRequest, response *[]index.Doc) error

Search 搜索

type ManagerServer

type ManagerServer struct {
	// contains filtered or unexported fields
}

func NewManagerServer

func NewManagerServer(config *config.Config) *ManagerServer

func (*ManagerServer) AddServer

func (m *ManagerServer) AddServer(request Node, response *Node) error

AddServer called by SearchServer

func (*ManagerServer) GetCluster

func (m *ManagerServer) GetCluster(request string, response *Cluster) error

GetCluster called by DataServer

func (*ManagerServer) ReBalance

func (m *ManagerServer) ReBalance() error

func (*ManagerServer) Run

func (m *ManagerServer) Run()

type Node

type Node struct {
	ID   int
	Type int
	Host string //ip:port

	LeaderSharding   []int //主分片
	FollowerSharding []int //备份分片
}

type SearchClient

type SearchClient struct {
	ServerConfig *config.Server //manager server config
	// contains filtered or unexported fields
}

func NewSearchClient

func NewSearchClient(config *config.Server) *SearchClient

func (*SearchClient) Search

func (c *SearchClient) Search(query string) ([]index.Doc, error)

type SearchRequest

type SearchRequest struct {
	Query    string
	Sharding []int
}

type SearchServer

type SearchServer struct {
	// contains filtered or unexported fields
}

func NewSearchServer

func NewSearchServer(config *config.Config) *SearchServer

func (*SearchServer) Run

func (s *SearchServer) Run()

func (*SearchServer) SearchAll

func (s *SearchServer) SearchAll(query string, response *[]index.Doc) error

SearchAll 分布式搜索 todo: 实现实时更新&删除接口

type Server

type Server struct {
	// contains filtered or unexported fields
}

func (*Server) RegisterName

func (s *Server) RegisterName(name string, rcvr interface{}) error

func (*Server) Run

func (s *Server) Run() error

func (*Server) Start

func (s *Server) Start() error

func (*Server) Stop

func (s *Server) Stop() error

type Sharding2Node

type Sharding2Node map[int][]Node

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL