Documentation ¶
Index ¶
- Constants
- Variables
- func Debugf(format string, a ...interface{})
- type Channel
- type Client
- type Connector
- type DB
- type Job
- type JobHandler
- type NetTransport
- type Streamer
- func (s *Streamer) Close(name string)
- func (s *Streamer) OpenRead(name string) io.ReadCloser
- func (s *Streamer) OpenReadWrite(name string) io.ReadWriter
- func (s *Streamer) OpenWrite(name string) io.WriteCloser
- func (s *Streamer) ReadFrom(src io.Reader, name string) (int64, error)
- func (s *Streamer) Shutdown() error
- func (s *Streamer) WriteTo(dst io.Writer, name string) (int64, error)
- type Worker
Constants ¶
const (
DEFAULTTIMEOUT = 0 // Wait forever
)
Variables ¶
var (
ErrInvalidResposeType = errors.New("Invalid response type")
)
Functions ¶
Types ¶
type Channel ¶
type Channel struct { SendEmptyResponseOnClose bool // contains filtered or unexported fields }
func NewChannel ¶
type Job ¶
type JobHandler ¶
type JobHandler func(name string, args []string, env map[string]string, streams *Streamer, db DB) error
A JobHandler is a function which can be invoked as a job by beam clients. The API for invoking jobs resembles that of unix processes:
- A job is invoked under a certain <name>.
- It may receive arguments as a string array (<args>).
- It may receive an environment as a map of key-value pairs (<env>).
- It may read from, and write to, streams of binary data. (<streams>).
- It returns value which can either indicate "success" or a variety of error conditions.
Additionally, a job may modify the server's database, which is shared with all other jobs. This is similar to how multiple unix processes share access to the same filesystem.
type NetTransport ¶
type Streamer ¶
func (*Streamer) Close ¶
Close closes the stream <name>. All future reads will return io.EOF, and writes will return io.ErrClosedPipe
func (*Streamer) OpenRead ¶
func (s *Streamer) OpenRead(name string) io.ReadCloser
OpenRead returns a read-only interface to receive data on the stream <name>. If the stream hasn't been open for read access before, it is advertised as such to the peer.
func (*Streamer) OpenReadWrite ¶
func (s *Streamer) OpenReadWrite(name string) io.ReadWriter
OpenReadWrite returns a read-write interface to send and receive on the stream <name>. If the stream hasn't been open for read or write access before, it is advertised as such to the peer.
func (*Streamer) OpenWrite ¶
func (s *Streamer) OpenWrite(name string) io.WriteCloser
OpenWrite returns a write-only interface to send data on the stream <name>. If the stream hasn't been open for write access before, it is advertised as such to the peer.
func (*Streamer) ReadFrom ¶
ReadFrom opens a read-only interface on the stream <name>, and copies data to that interface from <src> until EOF or error. The return value n is the number of bytes read. Any error encountered during the write is also returned.
func (*Streamer) Shutdown ¶
Shutdown waits until all streams with read access are closed and all WriteTo and ReadFrom operations are completed, then it stops accepting remote messages for its streams, then it returns.
type Worker ¶
type Worker struct { Prefix string // The prefix for all redis keys // contains filtered or unexported fields }
func (*Worker) RegisterJob ¶
func (w *Worker) RegisterJob(name string, h JobHandler)
RegisterJob exposes the function <h> as a remote job to be invoked by clients under the name <name>.
func (*Worker) ServeJob ¶
func (w *Worker) ServeJob(name string, args []string, env map[string]string, streams *Streamer, db DB) error
ServeJob is the server's default job handler. It is called every time a new job is created. It looks up a handler registered at <name>, and calls it with the same arguments. If no handler is registered, it returns an error.