api

package
v0.1.20 Latest Latest
Warning

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

Go to latest
Published: May 16, 2019 License: MIT Imports: 7 Imported by: 5

Documentation

Overview

Majordomo Protocol Client API. Implements the MDP/Worker spec at http://rfc.zeromq.org/spec:7.

Majordomo Protocol Client and Worker API. Implements the MDP/Worker spec at http://rfc.zeromq.org/spec:7.

Majordomo Protocol Worker API. Implements the MDP/Worker spec at http://rfc.zeromq.org/spec:7.

Index

Constants

View Source
const (
	HEARTBEAT_LIVENESS = 3                       // 3-5 is reasonable
	HEARTBEAT_INTERVAL = 2500 * time.Millisecond // msecs
	HEARTBEAT_EXPIRY   = HEARTBEAT_INTERVAL * HEARTBEAT_LIVENESS
)

TODO: get these from config data

View Source
const (
	// This is the version of MDP/Client we implement
	MDPC_CLIENT = "MDPC01"

	// This is the version of MDP/Worker we implement
	MDPW_WORKER = "MDPW01"
)
View Source
const (
	// MDP/Server commands, as strings
	MDPW_READY = string(iota + 1)
	MDPW_REQUEST
	MDPW_REPLY
	MDPW_HEARTBEAT
	MDPW_DISCONNECT
)

Variables

View Source
var (
	MDPS_COMMANDS = map[string]string{
		MDPW_READY:      "READY",
		MDPW_REQUEST:    "REQUEST",
		MDPW_REPLY:      "REPLY",
		MDPW_HEARTBEAT:  "HEARTBEAT",
		MDPW_DISCONNECT: "DISCONNECT",
	}
)

Functions

This section is empty.

Types

type Broker added in v0.1.20

type Broker struct {
	Socket *zmq.Socket // Socket for clients & workers

	Waiting     []*brokerWorker // List of waiting workers
	HeartbeatAt time.Time       // When to send HEARTBEAT
	// contains filtered or unexported fields
}

func NewBroker added in v0.1.20

func NewBroker() (broker *Broker, err error)

func (*Broker) Bind added in v0.1.20

func (b *Broker) Bind(endpoint string) (err error)

func (*Broker) ClientMsg added in v0.1.20

func (b *Broker) ClientMsg(sender string, msg []string)

func (*Broker) Close added in v0.1.20

func (b *Broker) Close() (err error)

func (*Broker) Purge added in v0.1.20

func (b *Broker) Purge()

func (*Broker) Run added in v0.1.20

func (b *Broker) Run(done chan bool)

func (*Broker) ServiceRequire added in v0.1.20

func (b *Broker) ServiceRequire(service_frame string) (service *Service)

func (*Broker) WorkerMsg added in v0.1.20

func (b *Broker) WorkerMsg(sender string, msg []string)

type Client

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

Majordomo Protocol Client API.

func NewClient

func NewClient(broker string) (c *Client, err error)

func (*Client) Close

func (c *Client) Close() (err error)

func (*Client) ConnectToBroker

func (c *Client) ConnectToBroker() (err error)

Connect or reconnect to broker. In this asynchronous class we use a DEALER socket instead of a REQ socket; this lets us send any number of requests without waiting for a reply.

func (*Client) Recv

func (c *Client) Recv() (msg []string, err error)

func (*Client) Send

func (c *Client) Send(service string, request ...string) (err error)

The send method now just sends one message, without waiting for a reply. Since we're using a DEALER socket we have to send an empty frame at the start, to create the same envelope that the REQ socket would normally make for us:

func (*Client) SetTimeout

func (c *Client) SetTimeout(timeout time.Duration)

Set request timeout.

type Service added in v0.1.20

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

func (*Service) Dispatch added in v0.1.20

func (s *Service) Dispatch(msg []string)

type Worker

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

Majordomo Protocol Worker API.

func NewWorker

func NewWorker(broker, service string) (w *Worker, err error)

func (*Worker) Close

func (w *Worker) Close()

func (*Worker) ConnectToBroker

func (w *Worker) ConnectToBroker() (err error)

Connect or reconnect to broker.

func (*Worker) Recv

func (w *Worker) Recv(reply []string) (msg []string, err error)

Send reply, if any, to broker and wait for next request.

func (*Worker) SendToBroker

func (w *Worker) SendToBroker(command string, option string, msg []string) (err error)

Send message to broker.

func (*Worker) SetHeartbeat

func (w *Worker) SetHeartbeat(heartbeat time.Duration)

Set heartbeat delay.

func (*Worker) SetReconnect

func (w *Worker) SetReconnect(reconnect time.Duration)

Set reconnect delay.

Jump to

Keyboard shortcuts

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