store

package
v0.0.0-...-fe81f67 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2019 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// RuleType denotes the rules.Rule type
	RuleType MessageType = 0
	// ScriptType denotes the script type
	ScriptType = 1
	// RecordType denotes the executions.Record type
	RecordType = 2
)

Variables

This section is empty.

Functions

func NewTCPTransport

func NewTCPTransport(
	bindListener net.Listener,
	advertise net.Addr,
	maxPool int,
	timeout time.Duration,
	logOutput io.Writer,
) (*raft.NetworkTransport, error)

NewTCPTransport returns a NetworkTransport that is built on top of a TCP streaming transport layer.

func NewTCPTransportWithConfig

func NewTCPTransportWithConfig(
	bindListener net.Listener,
	advertise net.Addr,
	config *raft.NetworkTransportConfig,
) (*raft.NetworkTransport, error)

NewTCPTransportWithConfig returns a NetworkTransport that is built on top of a TCP streaming transport layer, using the given config struct.

func NewTCPTransportWithLogger

func NewTCPTransportWithLogger(
	bindListener net.Listener,
	advertise net.Addr,
	maxPool int,
	timeout time.Duration,
	logger *log.Logger,
) (*raft.NetworkTransport, error)

NewTCPTransportWithLogger returns a NetworkTransport that is built on top of a TCP streaming transport layer, with log output going to the supplied Logger

Types

type Command

type Command struct {
	Op       string             `json:"op"` // stash or evict
	Rule     *rules.Rule        `json:"rule,omitempty"`
	RuleID   string             `json:"ruleID,omitempty"`
	Event    *events.Event      `json:"event,omitempty"`
	ScriptID string             `json:"script_id,omitempty"`
	Script   *js.Script         `json:"script,omitempty"`
	Record   *executions.Record `json:"record,omitempty"`
	RecordID string             `json:"record_id,omitempty"`
}

Command is the container for a raft command

func (*Command) DecodeMsg

func (z *Command) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*Command) EncodeMsg

func (z *Command) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*Command) MarshalMsg

func (z *Command) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*Command) Msgsize

func (z *Command) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*Command) UnmarshalMsg

func (z *Command) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type MessageType

type MessageType uint8

MessageType of the data entry

type Messages

type Messages struct {
	Rules   map[string]*rules.Rule        `json:"rules"`
	Records map[string]*executions.Record `json:"records"`
	Scripts map[string]*js.Script         `json:"script"`
}

Messages store entries to the underlying storage

type Node

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

Node represents a raft node

func NewNode

func NewNode(cfg *config.Config) (*Node, error)

NewNode returns a new raft node

func (*Node) AddRule

func (n *Node) AddRule(rule *rules.Rule) error

AddRule adds a rule to the store

func (*Node) AddScript

func (n *Node) AddScript(script *js.Script) error

AddScript adds a script to the db

func (*Node) GetRule

func (n *Node) GetRule(ruleID string) *rules.Rule

GetRule returns all the stored rules

func (*Node) GetRuleExectutions

func (n *Node) GetRuleExectutions(ruleID string) []*executions.Record

GetRuleExectutions returns the executions for a rule

func (*Node) GetRules

func (n *Node) GetRules() []*rules.Rule

GetRules returns all the stored rules

func (*Node) GetScript

func (n *Node) GetScript(id string) *js.Script

GetScript returns the script data

func (*Node) GetScripts

func (n *Node) GetScripts() []string

GetScripts returns all script ids

func (*Node) Join

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

Join a remote node at the addr

func (*Node) LeaderAddr

func (n *Node) LeaderAddr() string

LeaderAddr returns the http addr of the leader of the cluster. If empty, the current node is the leader

func (*Node) Leave

func (n *Node) Leave(nodeID string) error

Leave a remote node

func (*Node) RemoveRule

func (n *Node) RemoveRule(ruleID string) error

RemoveRule removes a rule from the store

func (*Node) RemoveScript

func (n *Node) RemoveScript(id string) error

RemoveScript remove a script from the db

func (*Node) Shutdown

func (n *Node) Shutdown() error

Shutdown the node

func (*Node) Snapshot

func (n *Node) Snapshot() error

Snapshot takes a snapshot of the store

func (*Node) Start

func (n *Node) Start() error

Start the node

func (*Node) Stash

func (n *Node) Stash(event *events.Event) error

Stash adds a event to the store

func (*Node) UpdateRule

func (n *Node) UpdateRule(rule *rules.Rule) error

UpdateRule updates a rule to the store

func (*Node) UpdateScript

func (n *Node) UpdateScript(script *js.Script) error

UpdateScript updates an already added script

type TCPStreamLayer

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

TCPStreamLayer implements StreamLayer interface for plain TCP.

func (*TCPStreamLayer) Accept

func (t *TCPStreamLayer) Accept() (c net.Conn, err error)

Accept implements the net.Listener interface.

func (*TCPStreamLayer) Addr

func (t *TCPStreamLayer) Addr() net.Addr

Addr implements the net.Listener interface.

func (*TCPStreamLayer) Close

func (t *TCPStreamLayer) Close() (err error)

Close implements the net.Listener interface.

func (*TCPStreamLayer) Dial

func (t *TCPStreamLayer) Dial(address raft.ServerAddress, timeout time.Duration) (net.Conn, error)

Dial implements the StreamLayer interface.

Jump to

Keyboard shortcuts

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