newman

package module
v0.0.0-...-31618c0 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2016 License: MIT Imports: 5 Imported by: 3

README

newman

A simple wrapper around an io.ReadWriteCloser used for message passing

Documentation

Index

Constants

View Source
const (
	DefaultBufferSize = 1024 * 100 // 100k
)

Variables

This section is empty.

Functions

func WrapNoopCloser

func WrapNoopCloser(rw io.ReadWriter) io.ReadWriteCloser

WrapNoopCloser wraps a io.ReadWriter in a io.ReadWriteCloser that does nothing on "Close"

Types

type Backoff

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

Backoff is a waiter that sleeps when Wait() is called

func (*Backoff) Reset

func (b *Backoff) Reset()

Reset sets the sleep duration back to it's starting value

func (*Backoff) Wait

func (b *Backoff) Wait()

Wait sleeps when called, and then doubles the amount of time it will sleep on the next call

type Conn

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

Conn provides a wrapper around an io.ReadWriteCloser for sending size delimited data over any reader/writer

func NewConn

func NewConn(rwc io.ReadWriteCloser) *Conn

NewConn returns a new Conn with the appropriate configuration

func (*Conn) Generate

func (c *Conn) Generate(f func() Message) (<-chan Message, context.CancelFunc)

Generate returns a channel that will recieve messages as they come in off the line Only safe to run once per Conn

func (*Conn) Next

func (c *Conn) Next(m Message) error

Next reads the next message off the line and unmarshals it into the given message

func (*Conn) SetWaiter

func (c *Conn) SetWaiter(w Waiter)

SetWaitFunc takes a function that will be called whenever the connection needs to wait before reading/writing

func (*Conn) Write

func (c *Conn) Write(m Message) error

Write a message to the connection

type Message

type Message interface {
	encoding.BinaryMarshaler
	encoding.BinaryUnmarshaler
}

type NoopCloser

type NoopCloser struct {
	io.ReadWriter
}

NoopCloser io.ReadWriteCloser has a noop for "Close"

func (*NoopCloser) Close

func (n *NoopCloser) Close() error

Close noop

type NoopWaiter

type NoopWaiter struct {
}

NoopWaiter does nothing when called

func (*NoopWaiter) Reset

func (n *NoopWaiter) Reset()

func (*NoopWaiter) Wait

func (n *NoopWaiter) Wait()

type Waiter

type Waiter interface {
	Wait()
	Reset()
}

Waiter provies a method for backing off reading/writing

Jump to

Keyboard shortcuts

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