cluster

package
v0.0.0-...-83fd405 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2021 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KeySep = ":"

	SectionConfig   = "config"
	SectionInstance = "instance"
	SectionPayload  = "payload"
)
View Source
const GlobalConfigName = "global"

Variables

View Source
var ErrCallbackIsNil = errors.New("callback is nil")
View Source
var ErrServiceGroupNotExist = errors.New("service group not exist")
View Source
var ErrServiceInfoNotExist = errors.New("service info not exist")
View Source
var ErrServiceInstanceAlreadyExist = errors.New("service instance already exist")

Functions

func GenKey

func GenKey(args ...interface{}) (key string)

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

func Logger

func Logger() log.ILogger

func ParseKey

func ParseKey(key string) (etcdRoot string, section string, serviceName string, serviceID int, err error)

func ParseKeyS

func ParseKeyS(key string) (etcdRoot string, section string, serviceName string, strServiceID string, err error)

func SetLogger

func SetLogger(l log.ILogger)

Types

type Cluster

type Cluster struct {
	*nactor.Actor
	// contains filtered or unexported fields
}

func NewCluster

func NewCluster(logger nlog.ILogger, etcdClient *netcdv3.Client) (c *Cluster)

func (*Cluster) AddWatchCallback

func (c *Cluster) AddWatchCallback(cb WatchCallback) (err error)

func (*Cluster) Close

func (c *Cluster) Close()

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

func (*Cluster) EtcdConfig

func (c *Cluster) EtcdConfig() netcd.Config

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

func (*Cluster) GenConfigKey

func (c *Cluster) GenConfigKey(serviceName string, serviceID int) string

func (*Cluster) GenConfigKeyPrefix

func (c *Cluster) GenConfigKeyPrefix(serviceName string) string

func (*Cluster) GenConfigKeyS

func (c *Cluster) GenConfigKeyS(serviceName string, strServiceID string) string

func (*Cluster) GenInstanceKey

func (c *Cluster) GenInstanceKey(serviceName string, serviceID int) string

func (*Cluster) GenInstanceKeyPrefix

func (c *Cluster) GenInstanceKeyPrefix(serviceName string) string

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

func (*Cluster) GenInstanceKeyS

func (c *Cluster) GenInstanceKeyS(serviceName string, strServiceID string) string

func (*Cluster) GenPayloadKey

func (c *Cluster) GenPayloadKey(serviceName string, serviceID int) string

func (*Cluster) GenPayloadKeyPrefix

func (c *Cluster) GenPayloadKeyPrefix(serviceName string) string

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

func (*Cluster) GenPayloadKeyS

func (c *Cluster) GenPayloadKeyS(serviceName string, strServiceID string) string

func (*Cluster) GetGlobalConfig

func (c *Cluster) GetGlobalConfig() (nexport.IGlobalConfig, error)

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

func (*Cluster) GetGlobalConfigKey

func (c *Cluster) GetGlobalConfigKey() string

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

func (*Cluster) GetServiceConfig

func (c *Cluster) GetServiceConfig(serviceName string, serviceID int) (nexport.IServiceConfig, error)

func (*Cluster) GetServiceGlobalConfig

func (c *Cluster) GetServiceGlobalConfig(serviceName string) (nexport.IServiceGlobalConfig, error)

func (*Cluster) GetServiceGroupAllInfo

func (c *Cluster) GetServiceGroupAllInfo(serviceName string) ([]*nservice.Info, error)

func (*Cluster) GetServiceInfo

func (c *Cluster) GetServiceInfo(serviceName string, serviceID nexport.ServiceID) (*nservice.Info, error)

func (*Cluster) GetServiceInfoNum

func (c *Cluster) GetServiceInfoNum(serviceName string) (num int, err error)

func (*Cluster) GetServiceInstance

func (c *Cluster) GetServiceInstance(serviceName string, serviceID nexport.ServiceID) (*nservice.Instance, error)

func (*Cluster) GetServiceInstanceNum

func (c *Cluster) GetServiceInstanceNum(serviceName string) (num int, err error)

func (*Cluster) GetServicePayload

func (c *Cluster) GetServicePayload(serviceName string, serviceID nexport.ServiceID) (nexport.Payload, error)

func (*Cluster) Init

func (c *Cluster) Init(etcdConfigFilePath string, globalConfig nexport.IClusterGlobalConfig, serviceGroupConfigMap ServiceGroupConfigMap) (err error)

func (*Cluster) LeaseID

func (c *Cluster) LeaseID() clientv3.LeaseID

func (*Cluster) ParseConfigKey

func (c *Cluster) ParseConfigKey(key string) (serviceName string, serviceID int, err error)

func (*Cluster) ParseConfigKeyS

func (c *Cluster) ParseConfigKeyS(key string) (serviceName string, strServiceID string, err error)

func (*Cluster) ParseInstanceKey

func (c *Cluster) ParseInstanceKey(key string) (serviceName string, serviceID int, err error)

func (*Cluster) ParseInstanceKeyS

func (c *Cluster) ParseInstanceKeyS(key string) (serviceName string, strServiceID string, err error)

func (*Cluster) ParsePayloadKey

func (c *Cluster) ParsePayloadKey(key string) (serviceName string, serviceID int, err error)

func (*Cluster) ParsePayloadKeyS

func (c *Cluster) ParsePayloadKeyS(key string) (serviceName string, strServiceID string, err error)

func (*Cluster) PutServiceInstance

func (c *Cluster) PutServiceInstance(serviceName string, serviceID nexport.ServiceID, instance *nservice.Instance) error

func (*Cluster) PutServicePayload

func (c *Cluster) PutServicePayload(serviceName string, serviceID nexport.ServiceID, payload nexport.Payload) error

func (*Cluster) RoundRobinPickServiceInstance

func (c *Cluster) RoundRobinPickServiceInstance(serviceName string) (info *nservice.Info, err error)

func (*Cluster) TryLockServicePosition

func (c *Cluster) TryLockServicePosition(serviceName string, serviceID nexport.ServiceID, instance *nservice.Instance) error

type ServiceGroupConfig

type ServiceGroupConfig struct {
	GlobalConfig nexport.IServiceGlobalConfig
	Config       nexport.IServiceConfig
}

type ServiceGroupConfigMap

type ServiceGroupConfigMap = map[string]ServiceGroupConfig

type WatchCallback

type WatchCallback func(err error, section string, serviceName string, serviceID int, ev *clientv3.Event)

Jump to

Keyboard shortcuts

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