mdapi

package
v0.0.0-...-f2f6987 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2014 License: BSD-2-Clause, MIT Imports: 5 Imported by: 0

Documentation

Overview

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

Index

Constants

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 Mdcli

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

Majordomo Protocol Client API.

func NewMdcli

func NewMdcli(broker string, verbose bool) (mdcli *Mdcli, err error)

func (*Mdcli) Close

func (mdcli *Mdcli) Close() (err error)

func (*Mdcli) ConnectToBroker

func (mdcli *Mdcli) ConnectToBroker() (err error)

Connect or reconnect to broker.

func (*Mdcli) Send

func (mdcli *Mdcli) Send(service string, request ...string) (reply []string, err error)

Here is the send method. It sends a request to the broker and gets a reply even if it has to retry several times. It returns the reply message, or error if there was no reply after multiple attempts:

func (*Mdcli) SetRetries

func (mdcli *Mdcli) SetRetries(retries int)

Set request retries.

func (*Mdcli) SetTimeout

func (mdcli *Mdcli) SetTimeout(timeout time.Duration)

Set request timeout.

type Mdcli2

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

Majordomo Protocol Client API.

func NewMdcli2

func NewMdcli2(broker string, verbose bool) (mdcli2 *Mdcli2, err error)

func (*Mdcli2) Close

func (mdcli2 *Mdcli2) Close() (err error)

func (*Mdcli2) ConnectToBroker

func (mdcli2 *Mdcli2) 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 (*Mdcli2) Recv

func (mdcli2 *Mdcli2) Recv() (msg []string, err error)

func (*Mdcli2) Send

func (mdcli2 *Mdcli2) 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 (*Mdcli2) SetTimeout

func (mdcli2 *Mdcli2) SetTimeout(timeout time.Duration)

Set request timeout.

type Mdwrk

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

Majordomo Protocol Worker API.

func NewMdwrk

func NewMdwrk(broker, service string, verbose bool) (mdwrk *Mdwrk, err error)

func (*Mdwrk) Close

func (mdwrk *Mdwrk) Close()

func (*Mdwrk) ConnectToBroker

func (mdwrk *Mdwrk) ConnectToBroker() (err error)

Connect or reconnect to broker.

func (*Mdwrk) Recv

func (mdwrk *Mdwrk) Recv(reply []string) (msg []string, err error)

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

func (*Mdwrk) SendToBroker

func (mdwrk *Mdwrk) SendToBroker(command string, option string, msg []string) (err error)

Send message to broker.

func (*Mdwrk) SetHeartbeat

func (mdwrk *Mdwrk) SetHeartbeat(heartbeat time.Duration)

Set heartbeat delay.

func (*Mdwrk) SetReconnect

func (mdwrk *Mdwrk) 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