Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RequestMultipleCn ¶ added in v1.1.0
func RequestMultipleCn(ctx context.Context, nodes []string, qs QueryService, genRequest func() *pb.Request, handleValidResponse func(string, *pb.Response), handleInvalidResponse func(string), ) error
RequestMultipleCn sends the request to multiple cn and wait the responses. nodes : the address of the multiple cn qs : QueryService genRequest : generate the specific Request based on the business handleValidResponse : valid response handler handleInvalidResponse : invalid response handler
Types ¶
type Config ¶
type Config struct { // Address is the address of query service. Address address.Address `toml:"address"` }
Config is the query service config.
type QueryService ¶
type QueryService interface { // SendMessage send message to a query service. SendMessage(ctx context.Context, address string, req *pb.Request) (*pb.Response, error) // NewRequest creates a new request by cmd method. NewRequest(pb.CmdMethod) *pb.Request // Release releases the response. Release(*pb.Response) // Start starts the service. Start() error // Close closes the service. Close() error // AddHandleFunc add message handler. AddHandleFunc(method pb.CmdMethod, h func(context.Context, *pb.Request, *pb.Response) error, async bool) // ServiceID return the uuid of current CN service ServiceID() string }
QueryService is used to send query request to another CN service.
func NewQueryService ¶
NewQueryService creates a new queryService instance.
type Session ¶
type Session interface { // GetUUIDString returns the id of the session. GetUUIDString() string // GetTenantName returns the tenant name of the session. GetTenantName() string // StatusSession converts the session to status.Session. StatusSession() *status.Session // SetSessionRoutineStatus set the session Status SetSessionRoutineStatus(status string) error }
Session is an interface which should have the following methods.
type SessionManager ¶
type SessionManager struct {
// contains filtered or unexported fields
}
SessionManager manages all sessions locally.
func NewSessionManager ¶
func NewSessionManager() *SessionManager
NewSessionManager creates a new SessionManager instance.
func (*SessionManager) AddSession ¶
func (sm *SessionManager) AddSession(s Session)
AddSession adds a new session to manager.
func (*SessionManager) GetAllSessions ¶
func (sm *SessionManager) GetAllSessions() []Session
GetAllSessions returns all sessions in the manager.
func (*SessionManager) GetSessionsByTenant ¶
func (sm *SessionManager) GetSessionsByTenant(tenant string) []Session
GetSessionsByTenant returns the sessions belongs to the tenant.
func (*SessionManager) RemoveSession ¶
func (sm *SessionManager) RemoveSession(s Session)
RemoveSession removes a session from manager.