Documentation
¶
Index ¶
- Constants
- Variables
- func Close() error
- func ConfigureReplica(replica map[uint64]ReplicaConfig)
- func Connect(address, username, password, database string) driver.Conn
- func DDLRaftMetadata(ctx context.Context) string
- func DHost() *dragonboat.NodeHost
- func DMLWriteRaftMetadataAsync(ctx context.Context) string
- func DQLReadRaftMetadata(ctx context.Context) string
- func ForEachReplica[T any](appType string, f func(ctx context.Context) error)
- func GetClickhouseConnection(ctx context.Context) driver.Conn
- func GetMetadata(ctx context.Context, namespace string) ([]byte, error)
- func Init() error
- func InitWithConfigFile(cfgFile string) error
- func Run(ctx context.Context, app raft.Application) error
- func RunReplica[T any](ctx context.Context, appID string, app raft.Application) (context.Context, error)
- func SetMetadata(ctx context.Context, namespace string, data []byte) error
- func WaitReady(ctx context.Context) (raft.EventLeaderUpdate, notifier.Subscription, error)
- func WithClickhouseStorage(address, username, password, database string)
- type Client
- type Command
- type Config
- type ContextKey
- type DragonboatConfig
- type DragonboatConfig2
- type HostConfig
- type Metadata
- type RaftContext
- type ReplicaConfig
- type UpdateRequest
Constants ¶
View Source
const Command_UpdateLeader = "update-leader"
Variables ¶
View Source
var ( ErrRaftContextNotFound = errors.New("raft context not found") ErrRaft = errors.New("raft error") // generic raft error )
Functions ¶
func ConfigureReplica ¶
func ConfigureReplica(replica map[uint64]ReplicaConfig)
func DDLRaftMetadata ¶
func DHost ¶
func DHost() *dragonboat.NodeHost
func DQLReadRaftMetadata ¶
func InitWithConfigFile ¶
func RunReplica ¶
func WaitReady ¶
func WaitReady(ctx context.Context) (raft.EventLeaderUpdate, notifier.Subscription, error)
"replicaID" that maps shard UID
func WithClickhouseStorage ¶
func WithClickhouseStorage( address, username, password, database string)
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
type Command ¶
type Command struct {
Command raft.Command `json:"command"`
Value json.RawMessage `json:"value"`
// ReplicaID of the requester
ReplicaID *uint64 `json:"replica_id,omitempty"`
}
Raft Command
type ContextKey ¶
type ContextKey string
type DragonboatConfig ¶
type DragonboatConfig2 ¶
type DragonboatConfig2 config2
func GetConfig ¶
func GetConfig() DragonboatConfig2
type HostConfig ¶
type HostConfig struct {
ReplicaID uint64 `mapstructure:"replica_id"`
RaftAddress string `mapstructure:"raft_address"`
WALDir string `mapstructure:"wal_dir"`
NodehostDir string `mapstructure:"nodehost_dir"`
DeploymentID uint64 `mapstructure:"deployment_id"`
Peer map[int]string `mapstructure:"peer"`
}
type Metadata ¶
type Metadata struct {
// AppliedIndex is the raft applied index
AppliedIndex *uint64 `json:"applied_index,omitempty"`
}
type RaftContext ¶
type RaftContext struct {
ID string
ShardID uint64
ReplicaID uint64
Type string
AppConfig any
DHost *dragonboat.NodeHost
ClickhouseConn driver.Conn
// contains filtered or unexported fields
}
func GetRaftContext ¶
func GetRaftContext(ctx context.Context) (RaftContext, error)
type ReplicaConfig ¶
type UpdateRequest ¶
type UpdateRequest struct {
CmdName Command `json:"cmd_name"`
CmdVer uint64 `json:"cmd_version"`
Data json.RawMessage `json:"data"`
}
UpdateRequest common Update request to state machine
Click to show internal directories.
Click to hide internal directories.