protocol

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2019 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrClientDisconnected = errors.New("Client is not connected to the server")

ErrClientDisconnected means a client was used while it was disconnected from the remote server

View Source
var ErrTimeout = errors.New("No new jobs available in given timeout")

ErrTimeout indicates that no new jobs were ready to be consumed within the given timeout duration

Functions

func ServeRPC added in v1.0.0

func ServeRPC(hub *goyaad.Hub, addr string) (io.Closer, error)

ServeRPC starts serving hub over rpc

Types

type RPCClient added in v1.0.0

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

RPCClient communicates with the Yaad RPC server

func (*RPCClient) Cancel added in v1.0.0

func (c *RPCClient) Cancel(id string) error

Cancel deletes a job identified by the given id. Calls to cancel are idempotent

func (*RPCClient) Close added in v1.0.0

func (c *RPCClient) Close() error

Close the client connection

func (*RPCClient) Connect added in v1.0.0

func (c *RPCClient) Connect(addr string) error

Connect to a Yaad RCP Server and return a connected client Once connected, a client may be used by multiple goroutines simultaneously.

func (*RPCClient) InspectN added in v1.0.0

func (c *RPCClient) InspectN(n int, jobs *[]*RPCJob) error

InspectN fetches upto n number of jobs from the server without consuming them

func (*RPCClient) Next added in v1.0.0

func (c *RPCClient) Next(timeout time.Duration) (string, []byte, error)

Next wait at-most timeout duration to return a ready job body from Yaad If no job is available within the timeout, ErrTimeout is returned and clients should try again later

func (*RPCClient) Ping added in v1.0.0

func (c *RPCClient) Ping() error

Ping the server and check connectivity

func (*RPCClient) Put added in v1.0.0

func (c *RPCClient) Put(body []byte, delay time.Duration) (string, error)

Put saves a job with Yaad and returns the auto-generated job id

func (*RPCClient) PutWithID added in v1.0.0

func (c *RPCClient) PutWithID(id string, body []byte, delay time.Duration) error

PutWithID saves a job with Yaad against a given id.

type RPCJob added in v1.0.0

type RPCJob struct {
	Body  []byte
	ID    string
	Delay time.Duration
}

RPCJob is a light wrapper struct representing job data on the wire without extra metadata that is stored internally

type RPCServer added in v1.0.0

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

RPCServer exposes a Yaad hub backed RPC endpoint

func (*RPCServer) Cancel added in v1.0.0

func (r *RPCServer) Cancel(id string, ignoredReply *int8) error

Cancel deletes the job pointed to by the id, reply is ignored If the job doesn't exist, no error is returned so calls to Cancel are idempotent

func (*RPCServer) InspectN added in v1.0.0

func (r *RPCServer) InspectN(n int, rpcJobs *[]*RPCJob) error

InspectN returns n jobs without removing them for ad-hoc inspection

func (*RPCServer) Next added in v1.0.0

func (r *RPCServer) Next(timeout time.Duration, job *RPCJob) error

Next sets the reply (job) to a valid job if a job is ready to be triggered If not job is ready yet, this call will wait (block) for the given duration and keep searching for ready jobs. If no job is ready by the end of the timeout, ErrTimeout is returned

func (*RPCServer) Ping added in v1.0.0

func (r *RPCServer) Ping(ignore int8, pong *string) error

Ping the server, sets "pong" as the reply useful for basic connectivity/liveness check

func (*RPCServer) PutWithID added in v1.0.0

func (r *RPCServer) PutWithID(job RPCJob, id *string) error

PutWithID accepts a new job and stores it in a Hub, reply is ignored

Jump to

Keyboard shortcuts

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