queryservice

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

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.

func (*Config) Adjust

func (c *Config) Adjust(machineHost, defaultListenAddress string)

Adjust adjust config, setup default configs

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

func NewQueryService(serviceID string, address string, cfg morpc.Config) (QueryService, error)

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.

Jump to

Keyboard shortcuts

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