server

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2021 License: Apache-2.0 Imports: 22 Imported by: 0 modules, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Application

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

Application a tcp application server

func NewApplication

func NewApplication(cfg Cfg) *Application

NewApplication returns a tcp application server

func NewApplicationWithDispatcher

func NewApplicationWithDispatcher(cfg Cfg, dispatcher func(req *raftcmdpb.Request, cmd interface{}, proxy raftstore.ShardsProxy) error) *Application

NewApplication returns a tcp application server

func (*Application) AsyncBroadcast

func (s *Application) AsyncBroadcast(cmd interface{}, group uint64, cb func(interface{}, [][]byte, error), timeout time.Duration, arg interface{}, mustLeader bool)

AsyncBroadcast broadcast to all current shards, and aggregate responses

func (*Application) AsyncExec

func (s *Application) AsyncExec(cmd interface{}, cb func(interface{}, []byte, error), arg interface{})

AsyncExec async exec the request command

func (*Application) AsyncExecWithGroupAndTimeout

func (s *Application) AsyncExecWithGroupAndTimeout(cmd interface{}, group uint64, cb func(interface{}, []byte, error), timeout time.Duration, arg interface{})

AsyncExecWithGroupAndTimeout async exec the request, if the err is ErrTimeout means the request is timeout

func (*Application) AsyncExecWithTimeout

func (s *Application) AsyncExecWithTimeout(cmd interface{}, cb func(interface{}, []byte, error), timeout time.Duration, arg interface{})

AsyncExecWithTimeout async exec the request, if the err is ErrTimeout means the request is timeout

func (*Application) Exec

func (s *Application) Exec(cmd interface{}, timeout time.Duration) ([]byte, error)

Exec exec the request command

func (*Application) ExecWithGroup

func (s *Application) ExecWithGroup(cmd interface{}, group uint64, timeout time.Duration) ([]byte, error)

ExecWithGroup exec the request command

func (*Application) ShardProxy

func (s *Application) ShardProxy() raftstore.ShardsProxy

ShardProxy returns the shard proxy

func (*Application) Start

func (s *Application) Start() error

Start start the application server

func (*Application) Stop

func (s *Application) Stop()

Stop stop redis server

type Cfg

type Cfg struct {
	Addr           string
	Store          raftstore.Store
	Handler        Handler
	ExternalServer bool
}

Cfg cfg

type Handler

type Handler interface {
	// BuildRequest build the request, fill the key, cmd, type,
	// and the custom type
	BuildRequest(*raftcmdpb.Request, interface{}) error
	// Codec returns the decoder and encoder to transfer request and response
	Codec() (codec.Encoder, codec.Decoder)
	// AddReadFunc add read handler func
	AddReadFunc(cmdType uint64, cb command.ReadCommandFunc)
	// AddWriteFunc add write handler func
	AddWriteFunc(cmdType uint64, cb command.WriteCommandFunc)
}

Handler is the request handler

type TestApplicationCluster

type TestApplicationCluster struct {
	RaftCluster  raftstore.TestRaftCluster
	Applications []*Application
	// contains filtered or unexported fields
}

TestApplicationCluster test application cluster, it based on raftstore.TestClusterStore.

func NewTestApplicationCluster

func NewTestApplicationCluster(t *testing.T, applicationFactory func(i int, store raftstore.Store) *Application, opts ...raftstore.TestClusterOption) *TestApplicationCluster

NewTestApplicationCluster returns TestApplicationCluster

func (*TestApplicationCluster) Start

func (c *TestApplicationCluster) Start()

Start start the application cluster

func (*TestApplicationCluster) Stop

func (c *TestApplicationCluster) Stop()

Stop stop the application cluster

Jump to

Keyboard shortcuts

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