sca

package
v0.0.0-...-c490aa8 Latest Latest
Warning

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

Go to latest
Published: May 9, 2019 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ROOT   = "root"
	LEAF   = "leaf"
	BRANCH = "branch"
	EXIT   = ""
)

Variables

View Source
var (
	ErrorListen = errors.New("Failed to listen")
	ErrorDial   = errors.New("Failed to dial")
	ErrorSock   = errors.New("Failed to new socket")
	ErrorDecode = errors.New("Failed to decode")
	ErrorEncode = errors.New("Failed to encode")
	ErrorSend   = errors.New("Failed to send")
	ErrorRecv   = errors.New("Failed to receive")
)

Functions

func FirstIPV4

func FirstIPV4() (ip net.IP)

firstIp returns first ip address

func Kill

func Kill(closers ...io.Closer) (err error)

Types

type Action

type Action func(context.Context, Payload) (Payload, error)

type Actions

type Actions struct{ sync.Map }

func (*Actions) Add

func (m *Actions) Add(name string, action Action)

func (*Actions) Get

func (m *Actions) Get(name string) (a Action, ok bool)

func (*Actions) Names

func (m *Actions) Names() (names []string)

func (*Actions) New

func (m *Actions) New(action Action) (name string)

type Config

type Config struct {
	RunnerName   string
	RunnerListen string
	LeaderListen string
	RunnerIp     string
}

func (*Config) FromEnv

func (cfg *Config) FromEnv() (err error)

type DataObject

type DataObject []byte

func (DataObject) Clone

func (d DataObject) Clone() (dup DataObject)

func (*DataObject) CodecDecodeSelf

func (x *DataObject) CodecDecodeSelf(d *codec1978.Decoder)

func (DataObject) CodecEncodeSelf

func (x DataObject) CodecEncodeSelf(e *codec1978.Encoder)

func (DataObject) Decode

func (d DataObject) Decode(i interface{}) (err error)

func (*DataObject) Encode

func (d *DataObject) Encode(i interface{}) (err error)

type Event

type Event struct {
	Id       int64             `codec:"id"`
	To       Targets           `codec:"to"`
	From     string            `codec:"from"`
	Action   string            `codec:"action"`
	Carrier  map[string]string `codec:"carrier"`
	Payload  Payload           `codec:"payload"`
	Callback string            `codec:"callback"`
}

func (*Event) Clone

func (e *Event) Clone() (dup *Event)

func (*Event) CodecDecodeSelf

func (x *Event) CodecDecodeSelf(d *codec1978.Decoder)

func (*Event) CodecEncodeSelf

func (x *Event) CodecEncodeSelf(e *codec1978.Encoder)

type Node

type Node struct {
	Name   string
	Listen string
	// contains filtered or unexported fields
}

func (*Node) Close

func (n *Node) Close() (err error)

func (*Node) Exit

func (n *Node) Exit(ctx context.Context) (err error)

func (*Node) Login

func (n *Node) Login(ctx context.Context, name, listen string) (err error)

func (*Node) Logout

func (n *Node) Logout(ctx context.Context, name string) (err error)

func (*Node) Recv

func (n *Node) Recv(ctx context.Context, e *Event) (err error)

func (*Node) Send

func (n *Node) Send(ctx context.Context, e *Event) (err error)

type Payload

type Payload []DataObject

func (*Payload) CodecDecodeSelf

func (x *Payload) CodecDecodeSelf(d *codec1978.Decoder)

func (Payload) CodecEncodeSelf

func (x Payload) CodecEncodeSelf(e *codec1978.Encoder)

type RetryOpts

type RetryOpts []retry.Option

func (RetryOpts) Dial

func (opts RetryOpts) Dial(sock mangos.Socket, addr string) (err error)

func (RetryOpts) Listen

func (opts RetryOpts) Listen(sock mangos.Socket, addr string) (err error)

func (RetryOpts) Recv

func (opts RetryOpts) Recv(sock mangos.Socket) (b []byte, err error)

func (RetryOpts) Send

func (opts RetryOpts) Send(sock mangos.Socket, b []byte) (err error)

type Rms

type Rms struct {
	Name string
	// contains filtered or unexported fields
}

func (*Rms) AddMember

func (r *Rms) AddMember(name string, node *Node)

func (*Rms) AddRoute

func (r *Rms) AddRoute(target, via string)

func (*Rms) DelMember

func (r *Rms) DelMember(name string)

func (*Rms) DelRoute

func (r *Rms) DelRoute(keys ...string)

func (*Rms) Dispatch

func (r *Rms) Dispatch(targets Targets) (local bool, ups Targets, vias map[string]Targets)

func (*Rms) GetMember

func (r *Rms) GetMember(name string) (node *Node, ok bool)

func (*Rms) GetRoute

func (r *Rms) GetRoute(target string) (via string)

func (*Rms) HasMember

func (r *Rms) HasMember() (ok bool)

func (*Rms) Members

func (r *Rms) Members() (names Set)

func (*Rms) Routes

func (r *Rms) Routes() (routes map[string]string)

func (*Rms) Targets

func (r *Rms) Targets(via string) (names []string)

type Runner

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

func NewRunner

func NewRunner(cfg *Config) (r *Runner, err error)

func (*Runner) AddAction

func (r *Runner) AddAction(name string, action Action)

func (*Runner) AddCallback

func (r *Runner) AddCallback(action Action) (name string)

func (*Runner) Close

func (r *Runner) Close() (err error)

func (*Runner) Derour

func (r *Runner) Derour(ctx context.Context, req Payload) (rep Payload, err error)

func (*Runner) Handle

func (r *Runner) Handle(ctx context.Context, e *Event) (err error)

func (*Runner) Leader

func (r *Runner) Leader() (leader *Node)

func (*Runner) Login

func (r *Runner) Login(ctx context.Context, req Payload) (rep Payload, err error)

Login name listen

func (*Runner) Logout

func (r *Runner) Logout(ctx context.Context, req Payload) (rep Payload, err error)

Logout name

func (*Runner) Member

func (r *Runner) Member(name string) *Node

func (*Runner) Members

func (r *Runner) Members() (members Set)

func (*Runner) Name

func (r *Runner) Name() string

func (*Runner) NodeType

func (r *Runner) NodeType() string

func (*Runner) Ping

func (r *Runner) Ping(ctx context.Context, req Payload) (rep Payload, err error)

Ping

func (*Runner) RemoveAction

func (r *Runner) RemoveAction(name string)

func (*Runner) Route

func (r *Runner) Route(ctx context.Context, req Payload) (rep Payload, err error)

func (*Runner) Routes

func (r *Runner) Routes() (routes map[string]string)

func (*Runner) Self

func (r *Runner) Self() *Node

func (*Runner) Wait

func (r *Runner) Wait() error

type Set

type Set map[string]bool

func NewSet

func NewSet(elems ...string) (set Set)

func (Set) Add

func (set Set) Add(elem string)

type Targets

type Targets []string

func (Targets) Clone

func (t Targets) Clone() (dup Targets)

Clone

func (*Targets) CodecDecodeSelf

func (x *Targets) CodecDecodeSelf(d *codec1978.Decoder)

func (Targets) CodecEncodeSelf

func (x Targets) CodecEncodeSelf(e *codec1978.Encoder)

func (Targets) Down

func (t Targets) Down() bool

Down - all nodes in the subtree a -> b -> c

    | -> d
    ` -> e -> f
if targets being exectured on node b, the action will be token on
node b, c, d,  e, and f

func (Targets) Local

func (t Targets) Local() bool

Local - local node of the subtree if `targets` being executed on node b, b is the local node.

func (*Targets) ToDown

func (t *Targets) ToDown()

ToDown - change to `Down'.

func (*Targets) ToLocal

func (t *Targets) ToLocal()

ToLocal - change to local

Jump to

Keyboard shortcuts

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