runner

package
v0.0.2-0...-95bbd96 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

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 Close

func Close() error

func ConfigureReplica

func ConfigureReplica(replica map[uint64]ReplicaConfig)

func Connect

func Connect(address, username, password, database string) driver.Conn

As root

func DDLRaftMetadata

func DDLRaftMetadata(ctx context.Context) string

func DHost

func DHost() *dragonboat.NodeHost

func DMLWriteRaftMetadataAsync

func DMLWriteRaftMetadataAsync(ctx context.Context) string

func DQLReadRaftMetadata

func DQLReadRaftMetadata(ctx context.Context) string

func ForEachReplica

func ForEachReplica[T any](appType string, f func(ctx context.Context) error)

func GetClickhouseConnection

func GetClickhouseConnection(ctx context.Context) driver.Conn

func GetMetadata

func GetMetadata(ctx context.Context, namespace string) ([]byte, error)

func Init

func Init() error

func InitWithConfigFile

func InitWithConfigFile(cfgFile string) error

func Run

func Run(ctx context.Context, app raft.Application) error

func RunReplica

func RunReplica[T any](ctx context.Context, appID string, app raft.Application) (context.Context, error)

func SetMetadata

func SetMetadata(ctx context.Context, namespace string, data []byte) error

func WaitReady

"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
}

func NewClient

func NewClient(ctx context.Context) (*Client, error)

func (*Client) Publish

func (c *Client) Publish(ctx context.Context, command raft.Command, msg any) ([]byte, uint64, error)

func (*Client) Query

func (c *Client) Query(ctx context.Context, msg any) (any, error)

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 Config

type Config[T any] struct {
	Host      *dragonboat.NodeHost
	ShardID   uint64
	ReplicaID uint64

	ID        string
	Alias     string
	Type      string
	AppConfig T
	// contains filtered or unexported fields
}

type ContextKey

type ContextKey string

type DragonboatConfig

type DragonboatConfig struct {
	ReplicaID    uint64                  `json:"replica_id"`
	RaftAddress  string                  `json:"raft_address"`
	WALDir       string                  `json:"wal_dir"`
	NodehostDir  string                  `json:"nodehost_dir"`
	DeploymentID uint64                  `json:"deployment_id"`
	Shard        map[string]*shardConfig `json:"shard"`
}

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 ReplicaConfig struct {
	ShardID   uint64
	ReplicaID uint64

	Bootstrap bool   `yaml:"bootstrap"`
	ID        string `yaml:"id"`
	Alias     string `yaml:"alias"`
	Type      string `yaml:"type"`
	Config    string `yaml:"config"`
}

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

Jump to

Keyboard shortcuts

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