cluster

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2020 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ApplyCommandEvent = "CONFIG_CLUSTER:APPLY_COMMAND"

	WebsocketURLPath = "/gds/"

	PeerIDGetParam = "peer_id"
)
View Source
const (
	AddPeerCommand
	RemovePeerCommand

	InsertJobCommand
	DeleteJobCommand
	AcquireJobCommand
	JobExecutedCommand
)

Variables

View Source
var (
	ErrNoLeader                   = errors.New("no leader in cluster")
	ErrLeaderClientNotInitialized = errors.New("leader client not initialized")
	ErrNotLeader                  = errors.New("node is not a leader")
)

Functions

func PrepareAcquireJobCommand

func PrepareAcquireJobCommand(jobKeys []string, peerID string) []byte

func PrepareAddPeerCommand

func PrepareAddPeerCommand(peerID string) []byte

func PrepareDeleteJobCommand

func PrepareDeleteJobCommand(key string) []byte

func PrepareInsertJobCommand

func PrepareInsertJobCommand(jobType string, data []byte) []byte

func PrepareJobExecutedCommand

func PrepareJobExecutedCommand(jobKey, err string, executedTime time.Time) []byte

func PrepareRemovePeerCommand

func PrepareRemovePeerCommand(peerID string) []byte

Types

type AcquireJob

type AcquireJob struct {
	JobKeys []string
	PeerID  string
}

type AddPeer

type AddPeer struct {
	PeerID string
}

type ApplyLogResponse

type ApplyLogResponse struct {
	ApplyError string
	Result     json2.RawMessage
}

func (ApplyLogResponse) Error

func (a ApplyLogResponse) Error() string

type Client

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

func NewRaftClusterClient

func NewRaftClusterClient(r *raft.Raft) *Client

func (*Client) IsLeader

func (client *Client) IsLeader() bool

func (*Client) Leader

func (client *Client) Leader() string

func (*Client) LeaderCh

func (client *Client) LeaderCh() <-chan bool

func (*Client) LocalID

func (client *Client) LocalID() string

func (*Client) Servers

func (client *Client) Servers() ([]string, error)

func (*Client) Shutdown

func (client *Client) Shutdown() error

func (*Client) SyncApply

func (client *Client) SyncApply(command []byte) (*ApplyLogResponse, error)

func (*Client) SyncApplyHelper

func (client *Client) SyncApplyHelper(command []byte, commandName string) (interface{}, error)

func (*Client) SyncApplyOnLeader

func (client *Client) SyncApplyOnLeader(command []byte) (*ApplyLogResponse, error)

type DeleteJob

type DeleteJob struct {
	Key string
}

type InsertJob

type InsertJob struct {
	Job  json2.RawMessage
	Type string
}

type JobExecuted

type JobExecuted struct {
	JobKey       string
	Error        string
	ExecutedTime time.Time
}

type RemovePeer

type RemovePeer struct {
	PeerID string
}

type SocketLeaderClient

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

func NewSocketLeaderClient

func NewSocketLeaderClient(leaderAddr, localID string) *SocketLeaderClient

func (*SocketLeaderClient) Ack

func (c *SocketLeaderClient) Ack(data []byte, timeout time.Duration) ([]byte, error)

func (*SocketLeaderClient) Close

func (c *SocketLeaderClient) Close()

func (*SocketLeaderClient) Dial

func (c *SocketLeaderClient) Dial(timeout time.Duration) error

Jump to

Keyboard shortcuts

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