meta

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2018 License: Apache-2.0 Imports: 10 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeResourceID

func MakeResourceID(rcTypeId []byte, idx uint32) string

func RegistBuilder

func RegistBuilder(name string, f builder)

func ResolveResourceID

func ResolveResourceID(rcId string) (rcTypeId []byte, err error)

Types

type Interface

type Interface interface {
	// RegistQuota 注册资源配额
	// resetInterval: 表示重置资源配额的时间间隔,单位秒
	// timestamp    : 注册时的时间戳
	RegistQuota(rcType []byte, quota uint32, resetInterval, timestamp int64) error

	// DeleteQuota 删除资源配额
	DeleteQuota(rcType []byte) error

	// Borrow 申请一次执行资格,如果成功返回nil
	// expire   : 表示申请的资源的自动回收时间
	// timestamp: 申请资源时的时间戳
	Borrow(rcType, clientId []byte, expire, timestamp int64) (string, error)

	// Return 归还执行资格,如果成功返回nil
	Return(clientId []byte, rcId string) error

	// ReturnAll 归还某个用户所有的执行资格,通常在用户主动关闭的时候
	// 返回回收的资源数量
	ReturnAll(rcType, clientId []byte) (uint32, error)

	// Recycle 清理到期未还的资源并且将recycled队列的资源投递到canBorrow队列
	Recycle(timestamp int64)

	// Resources 查询资源的信息
	// 如果rcType为空,将查询全量的资源信息
	ResourceList(rcType []byte) ([]*ResourceDetail, error)

	// Encode 将元数据序列化
	Encode() ([]byte, error)

	// Decode 将元数据反序列化
	Decode(b []byte) error
}

Interface 存储元数据的抽象接口,需要支持并发安全

func Default

func Default() Interface

func New

func New(name string) Interface

type PB_BorrowRecord

type PB_BorrowRecord struct {
	ClientID             []byte   `protobuf:"bytes,1,opt,name=ClientID,proto3" json:"ClientID,omitempty"`
	RCID                 string   `protobuf:"bytes,2,opt,name=RCID,proto3" json:"RCID,omitempty"`
	BorrowAt             int64    `protobuf:"varint,3,opt,name=BorrowAt,proto3" json:"BorrowAt,omitempty"`
	ExpireAt             int64    `protobuf:"varint,4,opt,name=ExpireAt,proto3" json:"ExpireAt,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*PB_BorrowRecord) Descriptor

func (*PB_BorrowRecord) Descriptor() ([]byte, []int)

func (*PB_BorrowRecord) GetBorrowAt

func (m *PB_BorrowRecord) GetBorrowAt() int64

func (*PB_BorrowRecord) GetClientID

func (m *PB_BorrowRecord) GetClientID() []byte

func (*PB_BorrowRecord) GetExpireAt

func (m *PB_BorrowRecord) GetExpireAt() int64

func (*PB_BorrowRecord) GetRCID

func (m *PB_BorrowRecord) GetRCID() string

func (*PB_BorrowRecord) ProtoMessage

func (*PB_BorrowRecord) ProtoMessage()

func (*PB_BorrowRecord) Reset

func (m *PB_BorrowRecord) Reset()

func (*PB_BorrowRecord) String

func (m *PB_BorrowRecord) String() string

func (*PB_BorrowRecord) XXX_DiscardUnknown

func (m *PB_BorrowRecord) XXX_DiscardUnknown()

func (*PB_BorrowRecord) XXX_Marshal

func (m *PB_BorrowRecord) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*PB_BorrowRecord) XXX_Merge

func (dst *PB_BorrowRecord) XXX_Merge(src proto.Message)

func (*PB_BorrowRecord) XXX_Size

func (m *PB_BorrowRecord) XXX_Size() int

func (*PB_BorrowRecord) XXX_Unmarshal

func (m *PB_BorrowRecord) XXX_Unmarshal(b []byte) error

type PB_Manager

type PB_Manager struct {
	RCType               []byte             `protobuf:"bytes,1,opt,name=RCType,proto3" json:"RCType,omitempty"`
	Quota                uint32             `protobuf:"varint,2,opt,name=Quota,proto3" json:"Quota,omitempty"`
	CanBorrow            []string           `protobuf:"bytes,3,rep,name=CanBorrow,proto3" json:"CanBorrow,omitempty"`
	Recycled             []string           `protobuf:"bytes,4,rep,name=Recycled,proto3" json:"Recycled,omitempty"`
	Used                 []*PB_BorrowRecord `protobuf:"bytes,5,rep,name=Used,proto3" json:"Used,omitempty"`
	UsedCount            uint32             `protobuf:"varint,6,opt,name=UsedCount,proto3" json:"UsedCount,omitempty"`
	ResetInterval        int64              `protobuf:"varint,7,opt,name=ResetInterval,proto3" json:"ResetInterval,omitempty"`
	LastReset            int64              `protobuf:"varint,8,opt,name=LastReset,proto3" json:"LastReset,omitempty"`
	XXX_NoUnkeyedLiteral struct{}           `json:"-"`
	XXX_unrecognized     []byte             `json:"-"`
	XXX_sizecache        int32              `json:"-"`
}

func (*PB_Manager) Descriptor

func (*PB_Manager) Descriptor() ([]byte, []int)

func (*PB_Manager) GetCanBorrow

func (m *PB_Manager) GetCanBorrow() []string

func (*PB_Manager) GetLastReset

func (m *PB_Manager) GetLastReset() int64

func (*PB_Manager) GetQuota

func (m *PB_Manager) GetQuota() uint32

func (*PB_Manager) GetRCType

func (m *PB_Manager) GetRCType() []byte

func (*PB_Manager) GetRecycled

func (m *PB_Manager) GetRecycled() []string

func (*PB_Manager) GetResetInterval

func (m *PB_Manager) GetResetInterval() int64

func (*PB_Manager) GetUsed

func (m *PB_Manager) GetUsed() []*PB_BorrowRecord

func (*PB_Manager) GetUsedCount

func (m *PB_Manager) GetUsedCount() uint32

func (*PB_Manager) ProtoMessage

func (*PB_Manager) ProtoMessage()

func (*PB_Manager) Reset

func (m *PB_Manager) Reset()

func (*PB_Manager) String

func (m *PB_Manager) String() string

func (*PB_Manager) XXX_DiscardUnknown

func (m *PB_Manager) XXX_DiscardUnknown()

func (*PB_Manager) XXX_Marshal

func (m *PB_Manager) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*PB_Manager) XXX_Merge

func (dst *PB_Manager) XXX_Merge(src proto.Message)

func (*PB_Manager) XXX_Size

func (m *PB_Manager) XXX_Size() int

func (*PB_Manager) XXX_Unmarshal

func (m *PB_Manager) XXX_Unmarshal(b []byte) error

type PB_Meta

type PB_Meta struct {
	Value                map[string]*PB_Manager `` /* 151-byte string literal not displayed */
	XXX_NoUnkeyedLiteral struct{}               `json:"-"`
	XXX_unrecognized     []byte                 `json:"-"`
	XXX_sizecache        int32                  `json:"-"`
}

func (*PB_Meta) Descriptor

func (*PB_Meta) Descriptor() ([]byte, []int)

func (*PB_Meta) GetValue

func (m *PB_Meta) GetValue() map[string]*PB_Manager

func (*PB_Meta) ProtoMessage

func (*PB_Meta) ProtoMessage()

func (*PB_Meta) Reset

func (m *PB_Meta) Reset()

func (*PB_Meta) String

func (m *PB_Meta) String() string

func (*PB_Meta) XXX_DiscardUnknown

func (m *PB_Meta) XXX_DiscardUnknown()

func (*PB_Meta) XXX_Marshal

func (m *PB_Meta) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*PB_Meta) XXX_Merge

func (dst *PB_Meta) XXX_Merge(src proto.Message)

func (*PB_Meta) XXX_Size

func (m *PB_Meta) XXX_Size() int

func (*PB_Meta) XXX_Unmarshal

func (m *PB_Meta) XXX_Unmarshal(b []byte) error

type ResourceDetail

type ResourceDetail struct {
	RCType         []byte
	Quota          uint32
	ResetInterval  int64
	CanBorrowCount uint32
	RecycledCount  uint32
	UsedCount      uint32
}

ResourceDetail 资源详情

Jump to

Keyboard shortcuts

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