fulfiller

package
v2.17.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2017 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package fulfiller provides a type that implements capnp.Answer that resolves by calling setter methods.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EmbargoClient

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

EmbargoClient is a client that flushes a queue of calls. Fulfiller will create these automatically when pipelined calls are made on unresolved answers. EmbargoClient is exported so that rpc can avoid making calls on its own Conn.

func (*EmbargoClient) Call

func (ec *EmbargoClient) Call(cl *capnp.Call) capnp.Answer

Call either queues a call to the underlying client or starts a call if the embargo has been lifted.

func (*EmbargoClient) Client

func (ec *EmbargoClient) Client() capnp.Client

Client returns the underlying client if the embargo has been lifted and nil otherwise.

func (*EmbargoClient) Close

func (ec *EmbargoClient) Close() error

Close closes the underlying client, rejecting any queued calls.

func (*EmbargoClient) TryQueue

func (ec *EmbargoClient) TryQueue(cl *capnp.Call) capnp.Answer

TryQueue will attempt to queue a call or return nil if the embargo has been lifted.

type Fulfiller

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

Fulfiller is a promise for a Struct. The zero value is an unresolved answer. A Fulfiller is considered to be resolved once Fulfill or Reject is called. Calls to the Fulfiller will queue up until it is resolved. A Fulfiller is safe to use from multiple goroutines.

func (*Fulfiller) Done

func (f *Fulfiller) Done() <-chan struct{}

Done returns a channel that is closed once f is resolved.

func (*Fulfiller) Fulfill

func (f *Fulfiller) Fulfill(s capnp.Struct)

Fulfill sets the fulfiller's answer to s. If there are queued pipeline calls, the capabilities on the struct will be embargoed until the queued calls finish. Fulfill will panic if the fulfiller has already been resolved.

func (*Fulfiller) Peek

func (f *Fulfiller) Peek() capnp.Answer

Peek returns f's resolved answer or nil if f has not been resolved. The Struct method of an answer returned from Peek returns immediately.

func (*Fulfiller) PipelineCall

func (f *Fulfiller) PipelineCall(transform []capnp.PipelineOp, call *capnp.Call) capnp.Answer

PipelineCall calls PipelineCall on the fulfilled answer or queues the call if f has not been fulfilled.

func (*Fulfiller) PipelineClose

func (f *Fulfiller) PipelineClose(transform []capnp.PipelineOp) error

PipelineClose waits until f is resolved and then calls PipelineClose on the fulfilled answer.

func (*Fulfiller) Reject

func (f *Fulfiller) Reject(err error)

Reject sets the fulfiller's answer to err. If there are queued pipeline calls, they will all return errors. Reject will panic if the error is nil or the fulfiller has already been resolved.

func (*Fulfiller) Struct

func (f *Fulfiller) Struct() (capnp.Struct, error)

Struct waits until f is resolved and returns its struct if fulfilled or an error if rejected.

Jump to

Keyboard shortcuts

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