component

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2024 License: MIT Imports: 38 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GossipKVCacheComponent

type GossipKVCacheComponent struct {
	micro.EmptyComponent

	// OnJoinCluster will be called when find a new leader or/and join a cluster, it might be called multiple times.
	OnJoinCluster func()
	// OnNodeJoin will be called when a node join the cluster
	OnNodeJoin func(*GossipKVCacheNodeMeta)
	// OnNodeLeave will be called when a node leave the cluster
	OnNodeLeave func(*GossipKVCacheNodeMeta)

	InMachineMode bool
	ClusterName   string

	Port int
	// contains filtered or unexported fields
}

GossipKVCacheComponent is Component for logging

func (*GossipKVCacheComponent) Add

func (c *GossipKVCacheComponent) Add(key, val string) error

Add a key-value to store

func (*GossipKVCacheComponent) AddKeys

func (c *GossipKVCacheComponent) AddKeys(keys []string, sameValue string) error

AddKeys add a lot of keys with same value to store

func (*GossipKVCacheComponent) Delete

func (c *GossipKVCacheComponent) Delete(key string) error

Delete a key-value from store

func (*GossipKVCacheComponent) FindMemberIPs

func (c *GossipKVCacheComponent) FindMemberIPs(cluster, service string) (string, string, error)

FindMemberIPs return global ip and private ip for node of given service in given cluster

func (*GossipKVCacheComponent) FindNodeMetasByPrefix

func (c *GossipKVCacheComponent) FindNodeMetasByPrefix(cluster, servicePrefix string) []*GossipKVCacheNodeMeta

FindNodeMetasByPrefix query the list of nodes that match the prefix.

func (*GossipKVCacheComponent) Get

func (c *GossipKVCacheComponent) Get(key string) (string, bool)

Get a value of key from store

func (*GossipKVCacheComponent) GetAll

func (c *GossipKVCacheComponent) GetAll() (map[string]string, error)

GetAll key-value pairs from store

func (*GossipKVCacheComponent) GetBroadcasts

func (c *GossipKVCacheComponent) GetBroadcasts(overhead, limit int) [][]byte

GetBroadcasts is called when user data messages can be broadcast. It can return a list of buffers to send. Each buffer should assume an overhead as provided with a limit on the total byte size allowed. The total byte size of the resulting data to send must not exceed the limit. Care should be taken that this method does not block, since doing so would block the entire UDP packet receive loop.

func (*GossipKVCacheComponent) GetMembers

func (c *GossipKVCacheComponent) GetMembers() []*memberlist.Node

GetMembers return all members in cluster

func (*GossipKVCacheComponent) HaveSensorID

func (c *GossipKVCacheComponent) HaveSensorID(sensorid string) error

HaveSensorID add an item with sensor id as key and c.ClusterName as value

func (*GossipKVCacheComponent) HaveSensorIDs

func (c *GossipKVCacheComponent) HaveSensorIDs(sensorids []string) error

HaveSensorIDs add a lot of items with sensorid as key and c.ClusterName as value

func (*GossipKVCacheComponent) Init

func (c *GossipKVCacheComponent) Init(server *micro.Server) error

Init the component

func (*GossipKVCacheComponent) LocalState

func (c *GossipKVCacheComponent) LocalState(join bool) []byte

LocalState is used for a TCP Push/Pull. This is sent to the remote side in addition to the membership information. Any data can be sent here. See MergeRemoteState as well. The `join` boolean indicates this is for a join instead of a push/pull.

func (*GossipKVCacheComponent) MergeRemoteState

func (c *GossipKVCacheComponent) MergeRemoteState(buf []byte, join bool)

MergeRemoteState is invoked after a TCP Push/Pull. This is the state received from the remote side and is the result of the remote side's LocalState call. The 'join' boolean indicates this is for a join instead of a push/pull.

func (*GossipKVCacheComponent) Name

func (c *GossipKVCacheComponent) Name() string

Name of the component

func (*GossipKVCacheComponent) NodeMeta

func (c *GossipKVCacheComponent) NodeMeta(limit int) []byte

NodeMeta is used to retrieve meta-data about the current node when broadcasting an alive message. Its length is limited to the given byte size. This metadata is available in the Node structure.

func (*GossipKVCacheComponent) NotifyJoin

func (c *GossipKVCacheComponent) NotifyJoin(node *memberlist.Node)

NotifyJoin is invoked when a node is detected to have joined. The Node argument must not be modified.

func (*GossipKVCacheComponent) NotifyLeave

func (c *GossipKVCacheComponent) NotifyLeave(node *memberlist.Node)

NotifyLeave is invoked when a node is detected to have left. The Node argument must not be modified.

func (*GossipKVCacheComponent) NotifyMsg

func (c *GossipKVCacheComponent) NotifyMsg(b []byte)

NotifyMsg is called when a user-data message is received. Care should be taken that this method does not block, since doing so would block the entire UDP packet receive loop. Additionally, the byte slice may be modified after the call returns, so it should be copied if needed

func (*GossipKVCacheComponent) NotifyUpdate

func (c *GossipKVCacheComponent) NotifyUpdate(node *memberlist.Node)

NotifyUpdate is invoked when a node is detected to have updated, usually involving the metadata. The Node argument must not be modified.

func (*GossipKVCacheComponent) PostStart

func (c *GossipKVCacheComponent) PostStart(ctx context.Context) error

PostStart called after Start()

func (*GossipKVCacheComponent) PreStop

func (c *GossipKVCacheComponent) PreStop(ctx context.Context) error

PreStop called before Stop()

func (*GossipKVCacheComponent) SensorIDHandlerWrapper

func (c *GossipKVCacheComponent) SensorIDHandlerWrapper(selfServiceName string, f echo.HandlerFunc, permitSelfHandlerFunc bool) echo.HandlerFunc

SensorIDHandlerWrapper return an echo.HandlerFunc that will forward/redirect request to the instance which serve with the sensor id if you need v2 version, if permitSelfHandlerFunc is true, use self handler func when no sensorID

func (*GossipKVCacheComponent) SensorIDsHandlerWrapper

func (c *GossipKVCacheComponent) SensorIDsHandlerWrapper(selfServiceName string, fhttp echo.HandlerFunc, fws func(*websocket.Conn, int, []byte) error) echo.HandlerFunc

SensorIDsHandlerWrapper return an echo.HandlerFunc that will forward/redirect request to the instances which serve with the sensorids

func (*GossipKVCacheComponent) SetupHandler

func (c *GossipKVCacheComponent) SetupHandler(root echoswagger.ApiRoot, base string) error

SetupHandler of echo if the component need

type GossipKVCacheNodeMeta

type GossipKVCacheNodeMeta struct {
	Name           string `json:"n,omitempty"`    //50
	InClusterIP    string `json:"inip,omitempty"` //15
	PrivateIP      string `json:"pip,omitempty"`  //15
	PrivateCluster string `json:"pc,omitempty"`   //15
	GlobalIP       string `json:"gip,omitempty"`  //15
	GlobalCluster  string `json:"gc,omitempty"`   //15
	ServiceName    string `json:"sn,omitempty"`   //50
	Port           int    `json:"p,omitempty"`    //5
	WorkLoad       int    `json:"wl,omitempty"`   // 5byte work-load quantity.
}

GossipKVCacheNodeMeta is meta for node, MetaMaxSize of member list is 512

type LoggerGroupComponent

type LoggerGroupComponent struct {
	micro.EmptyComponent
	// contains filtered or unexported fields
}

LoggerGroupComponent is Component for logging

func (*LoggerGroupComponent) Init

func (c *LoggerGroupComponent) Init(server *micro.Server) error

Init the component

func (*LoggerGroupComponent) Name

func (c *LoggerGroupComponent) Name() string

Name of the component

func (*LoggerGroupComponent) PostStop

func (c *LoggerGroupComponent) PostStop(ctx context.Context) error

PostStop called after Stop()

func (*LoggerGroupComponent) PreInit

func (c *LoggerGroupComponent) PreInit(ctx context.Context) error

PreInit called before Init()

func (*LoggerGroupComponent) SetDynamicConfig

func (c *LoggerGroupComponent) SetDynamicConfig(config *platformConf.NodeConfig) error

SetDynamicConfig called when get dynamic config for the first time

func (*LoggerGroupComponent) SetupHandler

func (c *LoggerGroupComponent) SetupHandler(root echoswagger.ApiRoot, base string) error

SetupHandler of echo if the component need

type LoggingComponent

type LoggingComponent struct {
	micro.EmptyComponent
	// contains filtered or unexported fields
}

LoggingComponent is Component for logging

func (*LoggingComponent) Init

func (c *LoggingComponent) Init(server *micro.Server) error

Init the component

func (*LoggingComponent) Name

func (c *LoggingComponent) Name() string

Name of the component

func (*LoggingComponent) PostStop

func (c *LoggingComponent) PostStop(ctx context.Context) error

PostStop called after Stop()

func (*LoggingComponent) PreInit

func (c *LoggingComponent) PreInit(ctx context.Context) error

PreInit called before Init()

func (*LoggingComponent) SetDynamicConfig

func (c *LoggingComponent) SetDynamicConfig(config *platformConf.NodeConfig) error

SetDynamicConfig called when get dynamic config for the first time

type MockComponent

type MockComponent struct {
	mock.Mock
}

MockComponent is an autogenerated mock type for the MockComponent type

func (*MockComponent) GetSubscribeServiceList

func (_m *MockComponent) GetSubscribeServiceList() []string

GetSubscribeServiceList provides a mock function with given fields:

func (*MockComponent) Init

func (_m *MockComponent) Init(server *micro.Server) error

Init provides a mock function with given fields: server

func (*MockComponent) Name

func (_m *MockComponent) Name() string

Name provides a mock function with given fields:

func (*MockComponent) OnConfigChanged

func (_m *MockComponent) OnConfigChanged(_a0 *conf.NodeConfig) error

OnConfigChanged provides a mock function with given fields: _a0

func (*MockComponent) OnServiceChanged

func (_m *MockComponent) OnServiceChanged(services []model.SubscribeService, err error)

OnServiceChanged provides a mock function with given fields: services, err

func (*MockComponent) PostInit

func (_m *MockComponent) PostInit(ctx context.Context) error

PostInit provides a mock function with given fields: ctx

func (*MockComponent) PostStart

func (_m *MockComponent) PostStart(ctx context.Context) error

PostStart provides a mock function with given fields: ctx

func (*MockComponent) PostStop

func (_m *MockComponent) PostStop(ctx context.Context) error

PostStop provides a mock function with given fields: ctx

func (*MockComponent) PreInit

func (_m *MockComponent) PreInit(ctx context.Context) error

PreInit provides a mock function with given fields: ctx

func (*MockComponent) PreStart

func (_m *MockComponent) PreStart(ctx context.Context) error

PreStart provides a mock function with given fields: ctx

func (*MockComponent) PreStop

func (_m *MockComponent) PreStop(ctx context.Context) error

PreStop provides a mock function with given fields: ctx

func (*MockComponent) SetDynamicConfig

func (_m *MockComponent) SetDynamicConfig(_a0 *conf.NodeConfig) error

SetDynamicConfig provides a mock function with given fields: _a0

func (*MockComponent) SetupHandler

func (_m *MockComponent) SetupHandler(root echoswagger.ApiRoot, base string) error

SetupHandler provides a mock function with given fields: root, base

func (*MockComponent) Start

func (_m *MockComponent) Start(ctx context.Context) error

Start provides a mock function with given fields: ctx

func (*MockComponent) Status

func (_m *MockComponent) Status() *micro.ComponentStatus

Status provides a mock function with given fields:

func (*MockComponent) Stop

func (_m *MockComponent) Stop(ctx context.Context) error

Stop provides a mock function with given fields: ctx

type RaftClusterComponent

type RaftClusterComponent struct {
	micro.EmptyComponent

	CreateFun statemachine.CreateStateMachineFunc

	ClusterID uint64
	// contains filtered or unexported fields
}

RaftClusterComponent is Component for logging

func (*RaftClusterComponent) Init

func (c *RaftClusterComponent) Init(server *micro.Server) error

Init the component

func (*RaftClusterComponent) Name

func (c *RaftClusterComponent) Name() string

Name of the component

func (*RaftClusterComponent) PostStart

func (c *RaftClusterComponent) PostStart(ctx context.Context) error

PostStart called after Start()

func (*RaftClusterComponent) PreInit

func (c *RaftClusterComponent) PreInit(ctx context.Context) error

PreInit called before Init()

func (*RaftClusterComponent) PreStop

func (c *RaftClusterComponent) PreStop(ctx context.Context) error

PreStop called before Stop()

func (*RaftClusterComponent) SetupHandler

func (c *RaftClusterComponent) SetupHandler(root echoswagger.ApiRoot, base string) error

SetupHandler of echo if the component need

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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