embedded

package
v0.0.0-...-8de5e17 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2016 License: Apache-2.0 Imports: 5 Imported by: 0

README

Creates client/coordinator pairs which use channels to communicate.

Meant to be used embedded in applications which do not need/want external coordination, especially tests.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewEmbeddedClient

func NewEmbeddedClient(taskchan chan metafora.Task, cmdchan chan *NodeCommand, nodechan chan []string) metafora.Client

func NewEmbeddedCoordinator

func NewEmbeddedCoordinator(nodeid string, taskchan chan metafora.Task, cmdchan chan *NodeCommand, nodechan chan []string) metafora.Coordinator

func NewEmbeddedPair

func NewEmbeddedPair(nodeid string) (metafora.Coordinator, metafora.Client)

Returns a connected client/coordinator pair for embedded/testing use

func NewStateStore

func NewStateStore() statemachine.StateStore

Types

type Commander

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

Commander is an embedable statemachine.Commander implementation. Task-specific command listeners are created by calling NewListener.

func NewCommander

func NewCommander() *Commander

NewCommander creates a new statemachine.Commander implementation.

func (*Commander) NewListener

func (c *Commander) NewListener(taskID string) statemachine.CommandListener

NewListener creates a task specific command listener linked to an embedded Commander.

func (*Commander) Send

func (c *Commander) Send(taskID string, m *statemachine.Message) error

type EmbeddedClient

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

func (*EmbeddedClient) DeleteTask

func (ec *EmbeddedClient) DeleteTask(taskid string) error

func (*EmbeddedClient) Nodes

func (ec *EmbeddedClient) Nodes() ([]string, error)

func (*EmbeddedClient) SubmitCommand

func (ec *EmbeddedClient) SubmitCommand(nodeid string, command metafora.Command) error

func (*EmbeddedClient) SubmitTask

func (ec *EmbeddedClient) SubmitTask(t metafora.Task) error

type EmbeddedCoordinator

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

Coordinator which listens for tasks on a channel

func (*EmbeddedCoordinator) Claim

func (e *EmbeddedCoordinator) Claim(task metafora.Task) bool

func (*EmbeddedCoordinator) Close

func (e *EmbeddedCoordinator) Close()

func (*EmbeddedCoordinator) Command

func (e *EmbeddedCoordinator) Command() (metafora.Command, error)

func (*EmbeddedCoordinator) Done

func (e *EmbeddedCoordinator) Done(task metafora.Task)

func (*EmbeddedCoordinator) Init

func (*EmbeddedCoordinator) Name

func (e *EmbeddedCoordinator) Name() string

func (*EmbeddedCoordinator) Release

func (e *EmbeddedCoordinator) Release(task metafora.Task)

func (*EmbeddedCoordinator) Watch

func (e *EmbeddedCoordinator) Watch(out chan<- metafora.Task) error

type NodeCommand

type NodeCommand struct {
	Cmd    metafora.Command
	NodeId string
}

type StateChanged

type StateChanged struct {
	TaskID string
	State  *statemachine.State
}

type StateStore

type StateStore struct {

	// Stored is intended for tests to block until a Store() is called as an
	// alternative to time.Sleep()s.
	//
	// Will deliver asynchronously and drop states if there's no receivers.
	Stored chan StateChanged
	// contains filtered or unexported fields
}

StateStore is an in-memory implementation of statemachine.StateStore intended for use in tests.

func (*StateStore) Load

func (s *StateStore) Load(task metafora.Task) (*statemachine.State, error)

func (*StateStore) Store

func (s *StateStore) Store(task metafora.Task, state *statemachine.State) error

Jump to

Keyboard shortcuts

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