Documentation
¶
Index ¶
- func DecodeCommandResult[T any](data []byte) T
- func EncodeCommand(cmd Command) []byte
- func EncodeCommandResult(v any) []byte
- type AllocCommand
- type AllocCommandResult
- type Command
- type CommandType
- type Config
- type FreeCommand
- type FreeCommandResult
- type RegisterQuotaCommand
- func (c *RegisterQuotaCommand) LocalInvoke(storage *storage, entryIdx uint64) error
- func (c *RegisterQuotaCommand) RaftInvoke(ctx context.Context, nh *dragonboat.NodeHost, _ uint64, ...) (any, error)
- func (c *RegisterQuotaCommand) Result() statemachine.Result
- func (c *RegisterQuotaCommand) Type() CommandType
- type RegisterQuotaCommandResult
- type Storage
- func (s *Storage) AddRaftReplica(ctx context.Context, replicaID uint64, raftAddr string) (bool, error)
- func (s *Storage) AllShardsHealthy() bool
- func (s *Storage) Alloc(ctx context.Context, namespace, resource string, tokens, version int64) (int64, int64, bool, error)
- func (s *Storage) AwaitHealthy(ctx context.Context) error
- func (s *Storage) Free(ctx context.Context, namespace, resource string, tokens, version int64) (int64, int64, bool, error)
- func (s *Storage) RegisterQuota(ctx context.Context, namespace, resource string, cfg quota.Config) error
- func (s *Storage) RemoveRaftReplica(ctx context.Context, replicaID uint64) error
- func (s *Storage) Run(ctx context.Context) error
- func (s *Storage) ShardHealthy(shardID uint64) bool
- func (s *Storage) Shutdown(_ context.Context) error
- func (s *Storage) View(ctx context.Context, namespace, resource string) (int64, int64, int64, error)
- type ViewCommand
- type ViewCommandResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeCommandResult ¶
func EncodeCommand ¶
func EncodeCommandResult ¶
Types ¶
type AllocCommand ¶
type AllocCommand struct { Namespace string Resource string Tokens int64 Version int64 SMResult statemachine.Result }
func NewAllocCommand ¶
func NewAllocCommand(namespace, resource string, tokens, version int64) *AllocCommand
func (*AllocCommand) LocalInvoke ¶
func (c *AllocCommand) LocalInvoke(storage *storage, entryIdx uint64) error
func (*AllocCommand) RaftInvoke ¶
func (*AllocCommand) Result ¶
func (c *AllocCommand) Result() statemachine.Result
func (*AllocCommand) Type ¶
func (c *AllocCommand) Type() CommandType
type AllocCommandResult ¶
type Command ¶
type Command interface { Type() CommandType RaftInvoke(ctx context.Context, nh *dragonboat.NodeHost, shardID uint64, session *client.Session) (result any, err error) LocalInvoke(storage *storage, entryIdx uint64) error Result() statemachine.Result }
func DecodeCommand ¶
type CommandType ¶
type CommandType byte
const ( View CommandType = 1 Alloc CommandType = 2 Free CommandType = 3 RegisterQuota CommandType = 4 )
type Config ¶
type Config struct { BindAddress string `yaml:"bind_address"` BindPort int `yaml:"bind_port"` BindAddressFromHostname bool `yaml:"bind_address_from_hostname"` DeploymentID uint64 `yaml:"deployment_id"` ReplicaID uint64 `yaml:"replica_id"` ReplicaIDOverride string `yaml:"replica_id_override"` ShardID uint64 `yaml:"shard_id"` Shards uint64 `yaml:"shards"` Dir string `yaml:"dir"` }
type FreeCommand ¶
type FreeCommand struct { Namespace string Resource string Tokens int64 Version int64 SMResult statemachine.Result }
func NewFreeCommand ¶
func NewFreeCommand(namespace, resource string, tokens, version int64) *FreeCommand
func (*FreeCommand) LocalInvoke ¶
func (c *FreeCommand) LocalInvoke(storage *storage, entryIdx uint64) error
func (*FreeCommand) RaftInvoke ¶
func (*FreeCommand) Result ¶
func (c *FreeCommand) Result() statemachine.Result
func (*FreeCommand) Type ¶
func (c *FreeCommand) Type() CommandType
type FreeCommandResult ¶
type RegisterQuotaCommand ¶
type RegisterQuotaCommand struct { Namespace string Resource string Cfg quota.Config SMResult statemachine.Result }
func NewRegisterQuotaCommand ¶
func NewRegisterQuotaCommand(namespace, resource string, cfg quota.Config) *RegisterQuotaCommand
func (*RegisterQuotaCommand) LocalInvoke ¶
func (c *RegisterQuotaCommand) LocalInvoke(storage *storage, entryIdx uint64) error
func (*RegisterQuotaCommand) RaftInvoke ¶
func (*RegisterQuotaCommand) Result ¶
func (c *RegisterQuotaCommand) Result() statemachine.Result
func (*RegisterQuotaCommand) Type ¶
func (c *RegisterQuotaCommand) Type() CommandType
type RegisterQuotaCommandResult ¶
type RegisterQuotaCommandResult struct{}
type Storage ¶
type Storage struct {
// contains filtered or unexported fields
}
func NewStorage ¶
func (*Storage) AddRaftReplica ¶
func (*Storage) AllShardsHealthy ¶
func (*Storage) RegisterQuota ¶
func (*Storage) RemoveRaftReplica ¶
func (*Storage) ShardHealthy ¶
type ViewCommand ¶
type ViewCommand struct { Namespace string Resource string SMResult statemachine.Result }
func NewViewCommand ¶
func NewViewCommand(namespace, resource string) *ViewCommand
func (*ViewCommand) LocalInvoke ¶
func (c *ViewCommand) LocalInvoke(storage *storage, _ uint64) error
func (*ViewCommand) RaftInvoke ¶
func (*ViewCommand) Result ¶
func (c *ViewCommand) Result() statemachine.Result
func (*ViewCommand) Type ¶
func (c *ViewCommand) Type() CommandType
Click to show internal directories.
Click to hide internal directories.