mesh

package
v0.0.0-...-9d9859e Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2026 License: BSD-3-Clause Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultShardID = 1
)

Variables

This section is empty.

Functions

func NewMeshStateMachine

func NewMeshStateMachine(shardID, replicaID uint64) statemachine.IStateMachine

Types

type ApplyLawsPayload

type ApplyLawsPayload struct {
	LawFiles []string `json:"law_files"`
	DryRun   bool     `json:"dry_run,omitempty"`
}

type Client

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

func NewClient

func NewClient(baseURL string, logger zerolog.Logger) *Client

func (*Client) BroadcastCommand

func (c *Client) BroadcastCommand(ctx context.Context, cmd Command) (map[uint64]*CommandResult, error)

func (*Client) ExecuteCommand

func (c *Client) ExecuteCommand(ctx context.Context, cmd Command) (*CommandResult, error)

func (*Client) GetNodes

func (c *Client) GetNodes(ctx context.Context) ([]Node, error)

func (*Client) GetStatus

func (c *Client) GetStatus(ctx context.Context) (*MeshStatus, error)

type Command

type Command struct {
	ID        string            `json:"id"`
	Type      CommandType       `json:"type"`
	Payload   json.RawMessage   `json:"payload"`
	Metadata  map[string]string `json:"metadata,omitempty"`
	Timestamp time.Time         `json:"timestamp"`
}

type CommandResult

type CommandResult struct {
	ID        string          `json:"id"`
	Success   bool            `json:"success"`
	Output    json.RawMessage `json:"output,omitempty"`
	Error     string          `json:"error,omitempty"`
	Timestamp time.Time       `json:"timestamp"`
}

type CommandType

type CommandType string
const (
	CommandTypeExec      CommandType = "exec"
	CommandTypeFacts     CommandType = "facts"
	CommandTypeApplyLaws CommandType = "apply_laws"
)

type Config

type Config struct {
	ReplicaID          uint64
	ShardID            uint64
	RaftAddress        string
	DataDir            string
	InitialMembers     map[uint64]string
	Join               bool
	RTTMillisecond     uint64
	ElectionRTT        uint64
	HeartbeatRTT       uint64
	SnapshotEntries    uint64
	CompactionOverhead uint64
}

type ExecPayload

type ExecPayload struct {
	Command string            `json:"command"`
	Args    []string          `json:"args,omitempty"`
	Env     map[string]string `json:"env,omitempty"`
	WorkDir string            `json:"work_dir,omitempty"`
}

type ExecResult

type ExecResult struct {
	ExitCode int    `json:"exit_code"`
	Stdout   string `json:"stdout"`
	Stderr   string `json:"stderr"`
}

type FactsPayload

type FactsPayload struct {
	Categories []string `json:"categories,omitempty"`
}

type HTTPServer

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

func NewHTTPServer

func NewHTTPServer(service *Service, addr string, logger zerolog.Logger) *HTTPServer

func (*HTTPServer) Start

func (h *HTTPServer) Start() error

func (*HTTPServer) Stop

func (h *HTTPServer) Stop(ctx context.Context) error

type MeshService

type MeshService interface {
	Start(ctx context.Context) error
	Stop() error
	ExecuteCommand(ctx context.Context, cmd Command) (*CommandResult, error)
	BroadcastCommand(ctx context.Context, cmd Command) (map[uint64]*CommandResult, error)
	GetStatus() (*MeshStatus, error)
	GetNodes() ([]Node, error)
}

type MeshStateMachine

type MeshStateMachine struct {
	ShardID   uint64
	ReplicaID uint64
	// contains filtered or unexported fields
}

func (*MeshStateMachine) Close

func (m *MeshStateMachine) Close() error

func (*MeshStateMachine) Lookup

func (m *MeshStateMachine) Lookup(query interface{}) (interface{}, error)

func (*MeshStateMachine) RecoverFromSnapshot

func (m *MeshStateMachine) RecoverFromSnapshot(r io.Reader, files []statemachine.SnapshotFile, done <-chan struct{}) error

func (*MeshStateMachine) SaveSnapshot

func (m *MeshStateMachine) SaveSnapshot(w io.Writer, fc statemachine.ISnapshotFileCollection, done <-chan struct{}) error

func (*MeshStateMachine) StoreResult

func (m *MeshStateMachine) StoreResult(result *CommandResult)

func (*MeshStateMachine) Update

type MeshStatus

type MeshStatus struct {
	NodeID    uint64    `json:"node_id"`
	ShardID   uint64    `json:"shard_id"`
	IsLeader  bool      `json:"is_leader"`
	Nodes     []Node    `json:"nodes"`
	Timestamp time.Time `json:"timestamp"`
}

type Node

type Node struct {
	ID      uint64 `json:"id"`
	Address string `json:"address"`
	Status  string `json:"status"`
}

type Service

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

func NewService

func NewService(cfg Config, logger zerolog.Logger) (*Service, error)

func (*Service) BroadcastCommand

func (s *Service) BroadcastCommand(ctx context.Context, cmd Command) (map[uint64]*CommandResult, error)

func (*Service) ExecuteCommand

func (s *Service) ExecuteCommand(ctx context.Context, cmd Command) (*CommandResult, error)

func (*Service) GetNodes

func (s *Service) GetNodes() ([]Node, error)

func (*Service) GetStatus

func (s *Service) GetStatus() (*MeshStatus, error)

func (*Service) Start

func (s *Service) Start(ctx context.Context) error

func (*Service) Stop

func (s *Service) Stop() error

Jump to

Keyboard shortcuts

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