requestmanager

package
v1.0.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2018 License: MIT Imports: 4 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Request

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

Request represents a request created and tracked by the request manager

func (*Request) AwaitReply

func (req *Request) AwaitReply() (webwire.Payload, error)

AwaitReply blocks the calling goroutine until either the reply is fulfilled or failed or the request is timed out. The timer is started when AwaitReply is called.

func (*Request) Identifier

func (req *Request) Identifier() RequestIdentifier

Identifier returns the assigned request identifier

type RequestIdentifier

type RequestIdentifier = [8]byte

RequestIdentifier represents the universally unique minified UUIDv4 identifier of a request.

type RequestManager

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

RequestManager manages and keeps track of outgoing pending requests

func NewRequestManager

func NewRequestManager() RequestManager

NewRequestManager constructs and returns a new instance of a RequestManager

func (*RequestManager) Create

func (manager *RequestManager) Create(timeout time.Duration) *Request

Create creates and registers a new request. Create doesn't start the timeout timer, this is done in the subsequent request.AwaitReply

func (*RequestManager) Fail

func (manager *RequestManager) Fail(identifier RequestIdentifier, err error) bool

Fail fails the request associated with the given request identifier with the provided error. Returns true if a pending request was failed and deregistered, otherwise returns false

func (*RequestManager) Fulfill

func (manager *RequestManager) Fulfill(
	identifier RequestIdentifier,
	payload webwire.Payload,
) bool

Fulfill fulfills the request associated with the given request identifier with the provided reply payload. Returns true if a pending request was fulfilled and deregistered, otherwise returns false

func (*RequestManager) IsPending

func (manager *RequestManager) IsPending(identifier RequestIdentifier) bool

IsPending returns true if the request associated with the given identifier is pending

func (*RequestManager) PendingRequests

func (manager *RequestManager) PendingRequests() int

PendingRequests returns the number of currently pending requests

Jump to

Keyboard shortcuts

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