raft

package
v0.2.15 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AckPayload added in v0.1.14

type AckPayload struct {
	QueueName string `json:"queue_name"`
	ID        uint64 `json:"id"`
}

type Command

type Command struct {
	Op      string      `json:"op"`
	Payload interface{} `json:"payload"`
}

func (Command) MarshalJSON added in v0.1.14

func (c Command) MarshalJSON() ([]byte, error)

Custom marshal logic to encode the dynamic payload

func (*Command) UnmarshalJSON added in v0.1.14

func (c *Command) UnmarshalJSON(data []byte) error

Custom unmarshal logic to decode the dynamic payload based on the "op" field

type CreateQueuePayload added in v0.1.14

type CreateQueuePayload struct {
	QueueType string `json:"queue_type"`
	QueueName string `json:"queue_name"`
}

type DeleteQueuePayload added in v0.1.14

type DeleteQueuePayload struct {
	QueueName string `json:"queue_name"`
}

type DequeuePayload added in v0.1.14

type DequeuePayload struct {
	QueueName string `json:"queue_name"`
	Ack       bool   `json:"ack"`
}

type EnqueuePayload added in v0.1.14

type EnqueuePayload struct {
	ID        uint64 `json:"id"`
	QueueName string `json:"queue_name"`
	Group     string `json:"group"`
	Priority  int64  `json:"priority"`
	Content   string `json:"content"`
}

type FSM

type FSM struct {
	NodeID string
	// contains filtered or unexported fields
}

func (*FSM) Apply

func (f *FSM) Apply(raftLog *raft.Log) interface{}

func (*FSM) Restore

func (f *FSM) Restore(rc io.ReadCloser) error

func (*FSM) Snapshot

func (f *FSM) Snapshot() (raft.FSMSnapshot, error)

type FSMResponse

type FSMResponse struct {
	QueueName string
	ID        uint64
	Group     string
	Priority  int64
	Content   string
	// contains filtered or unexported fields
}

type FSMSnapshot

type FSMSnapshot struct {
	NodeID string
	// contains filtered or unexported fields
}

func (*FSMSnapshot) Persist

func (f *FSMSnapshot) Persist(sink raft.SnapshotSink) error

func (*FSMSnapshot) Release

func (f *FSMSnapshot) Release()

type NackPayload added in v0.1.14

type NackPayload struct {
	QueueName string `json:"queue_name"`
	ID        uint64 `json:"id"`
}

type Node

type Node struct {
	Raft         *raft.Raft
	QueueManager *queue.QueueManager
	// contains filtered or unexported fields
}

func NewNode

func NewNode(db *badger.DB, raftDir string, cfg *config.Config, peers []string) *Node

func (*Node) Ack

func (n *Node) Ack(QueueName string, id uint64) error

func (*Node) CreateQueue

func (n *Node) CreateQueue(queueType, queueName string) error

func (*Node) DeleteQueue

func (n *Node) DeleteQueue(queueName string) error

func (*Node) Dequeue

func (n *Node) Dequeue(QueueName string, ack bool) (*queue.Message, error)

func (*Node) Enqueue

func (n *Node) Enqueue(
	queueName string, group string, priority int64, content string,
) (*queue.Message, error)

func (*Node) GenerateID added in v0.1.14

func (node *Node) GenerateID() uint64

func (*Node) GetByID

func (n *Node) GetByID(id uint64) (*queue.Message, error)

func (*Node) GetQueueInfo added in v0.2.0

func (n *Node) GetQueueInfo(queueName string) (*queue.QueueInfo, error)

func (*Node) GetQueues added in v0.2.0

func (n *Node) GetQueues() []*queue.QueueInfo

func (*Node) InitIDGenerator added in v0.1.14

func (node *Node) InitIDGenerator() error

func (*Node) Initialize

func (node *Node) Initialize()

func (*Node) IsLeader

func (n *Node) IsLeader() bool

func (*Node) Join

func (n *Node) Join(nodeID, addr string) error

func (*Node) Leader

func (n *Node) Leader() string

func (*Node) ListenToLeaderChanges

func (node *Node) ListenToLeaderChanges()

func (*Node) Nack added in v0.2.4

func (n *Node) Nack(QueueName string, id uint64) error

func (*Node) PrometheusRegistry added in v0.2.0

func (node *Node) PrometheusRegistry() prometheus.Registerer

func (*Node) SetLeaderChangeFunc

func (node *Node) SetLeaderChangeFunc(leaderChangeFn func(bool))

func (*Node) UpdatePriority

func (n *Node) UpdatePriority(queueName string, id uint64, priority int64) error

type UpdatePriorityPayload added in v0.1.14

type UpdatePriorityPayload struct {
	QueueName string `json:"queue_name"`
	ID        uint64 `json:"id"`
	Priority  int64  `json:"priority"`
}

Jump to

Keyboard shortcuts

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