core

package
v0.0.0-...-68bdf18 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2018 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//“产品线名.业务组名.服务名”组成serviceKey用于标识一个服务,各字段限长30字节
	ServiceKeyCap = uint(92)
	//"section.key"组成服务的一个配置,各字段限长30字节
	ConfKeyCap = uint(61)
	//value支持最大200字节
	ConfValueCap     = uint(200)
	ServiceConfLimit = uint(100)
	//一个bucket用于存放一个Service的配置,可存多少种Service
	//[版本号:serviceKey长度:serviceKey:配置个数:配置k1长度:配置k1:配置v1长度:配置v1:......]
	//[2:2:92:2:[2:61:2:30]:[2:61:2:30]:...]
	OneBucketCap = 2 + 2 + ServiceKeyCap + 2 + ServiceConfLimit*(2+ConfKeyCap+2+ConfValueCap)
	//一个service总共可包含100个配置
	ServiceBucketLimit = uint(100)
	//配置总内存空间
	//[Service1][Service2][Service3]...最多100个
	TotalConfMemSize = OneBucketCap * ServiceBucketLimit
)
View Source
const (
	RootPath = "/tmp/sona"
)

Variables

This section is empty.

Functions

func AddServiceConf

func AddServiceConf(memory *[TotalConfMemSize]byte, idx uint,
	serviceKey string, version uint, confKeys []string, values []string)

添加一个service的配置,前提:confKey已按照字典序排序

func GetAllServiceIndex

func GetAllServiceIndex(memory *[TotalConfMemSize]byte) map[string]uint

获取目前内存中所有service配置所在索引位置

func GetConf

func GetConf(memory *[TotalConfMemSize]byte, serviceKey string, idx uint, confKey string) string

获取某service的某配置confKey的值

func GetConfCount

func GetConfCount(memory *[TotalConfMemSize]byte, idx uint) uint

接下来是某service具体信息的操作 获取某service里的配置个数

func GetServiceKey

func GetServiceKey(memory *[TotalConfMemSize]byte, idx uint) (string, uint)

获取某位置上的serviceKey与版本

func HasService

func HasService(memory *[TotalConfMemSize]byte, idx uint) bool

某位置是否有配置

func IsValidityConfKey

func IsValidityConfKey(key string) bool

func IsValidityServiceKey

func IsValidityServiceKey(key string) bool

func RemoveServiceConf

func RemoveServiceConf(memory *[TotalConfMemSize]byte, idx uint)

删除某service的配置

Types

type ConfigController

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

配置管理

func GetConfigController

func GetConfigController() (*ConfigController, error)

创建一个配合控制

func (*ConfigController) Close

func (cc *ConfigController) Close()

清理

func (*ConfigController) ForceRemoveService

func (cc *ConfigController) ForceRemoveService(serviceKey string)

强制删除某service的配置 无视版本(清理G触发)

func (*ConfigController) GetAllServiceKeys

func (cc *ConfigController) GetAllServiceKeys() map[string]uint

获取当前所有serviceKey与版本

func (*ConfigController) GetFirstIndexFree

func (cc *ConfigController) GetFirstIndexFree() uint

获取第一个可用索引

func (*ConfigController) IsServiceExist

func (cc *ConfigController) IsServiceExist(serviceKey string) bool

某serviceKey是否存在

func (*ConfigController) QueryIndex

func (cc *ConfigController) QueryIndex(serviceKey string) (uint, error)

查询某serviceKey的索引

func (*ConfigController) RemoveService

func (cc *ConfigController) RemoveService(serviceKey string, remoteVersion uint)

删除某service的配置 带版本 (broker数据到来触发)

func (*ConfigController) UpdateService

func (cc *ConfigController) UpdateService(serviceKey string, remoteVersion uint, configKeys []string, values []string) error

更新一个service的配置,来自于pull的回复 前提:配置数据不为空

type ConfigGetter

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

配置获取,代表一个serviceKey

func GetConfigGetter

func GetConfigGetter(serviceKey string, index uint) (*ConfigGetter, error)

创建一个配置获取

func (*ConfigGetter) Close

func (cg *ConfigGetter) Close()

清理

func (*ConfigGetter) Get

func (cg *ConfigGetter) Get(confKey string) string

读配置

type RdFlock

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

func (*RdFlock) Close

func (rl *RdFlock) Close()

func (*RdFlock) RDLock

func (rl *RdFlock) RDLock() error

上共享锁

func (*RdFlock) Release

func (rl *RdFlock) Release() error

type SharedMem

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

func (*SharedMem) Close

func (shm *SharedMem) Close()

与mmap取消关联

type WrFlock

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

func (*WrFlock) Close

func (wl *WrFlock) Close()

func (*WrFlock) RDLock

func (wl *WrFlock) RDLock() error

可以上共享锁

func (*WrFlock) Release

func (wl *WrFlock) Release() error

func (*WrFlock) WRLock

func (wl *WrFlock) WRLock() error

上互斥锁

func (*WrFlock) WRLockNoWait

func (wl *WrFlock) WRLockNoWait() error

上互斥锁(非阻塞)

Jump to

Keyboard shortcuts

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