beam

package
v0.10.1-0...-d91ddfa Latest Latest
Warning

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

Go to latest
Published: May 22, 2014 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	R = iota
	W
)

Variables

This section is empty.

Functions

func Connect

func Connect(ctx *UnixConn, name string) (net.Conn, error)

func Copy

func Copy(dst Sender, src Receiver) (int, error)

func FdConn

func FdConn(fd int) (n *net.UnixConn, err error)

FdConn wraps a file descriptor in a standard *net.UnixConn object, or returns an error if the file descriptor does not point to a unix socket. This creates a duplicate file descriptor. It's the caller's responsibility to close both.

func Listen

func Listen(conn Sender, name string) (net.Listener, error)

Listen is a convenience interface for applications to create service endpoints which can be easily used with existing networking code.

Listen registers a new service endpoint on the beam connection `conn`, using the service name `name`. It returns a listener which can be used in the usual way. Calling Accept() on the listener will block until a new connection is available on the service endpoint. The endpoint is then returned as a regular net.Conn and can be used as a regular network connection.

Note that if the underlying file descriptor received in attachment is nil or does not point to a connection, that message will be skipped.

func MsgDesc

func MsgDesc(payload []byte, attachment *os.File) string

MsgDesc returns a human readable description of a beam message, usually for debugging purposes.

func SendRPipe

func SendRPipe(dst Sender, data []byte) (*os.File, error)

SendRPipe create a pipe and sends its *read* end attached in a beam message to `dst`, with `data` as the message payload. It returns the *write* end of the pipe, or an error.

func SendWPipe

func SendWPipe(dst Sender, data []byte) (*os.File, error)

SendWPipe create a pipe and sends its *read* end attached in a beam message to `dst`, with `data` as the message payload. It returns the *write* end of the pipe, or an error.

func SocketPair

func SocketPair() (a *os.File, b *os.File, err error)

SocketPair is a convenience wrapper around the socketpair(2) syscall. It returns a unix socket of type SOCK_STREAM in the form of 2 file descriptors not bound to the underlying filesystem. Messages sent on one end are received on the other, and vice-versa. It is the caller's responsibility to close both ends.

func USocketPair

func USocketPair() (*UnixConn, *UnixConn, error)

Types

type ReceiveCloser

type ReceiveCloser interface {
	Receiver
	Close() error
}

type ReceiveSender

type ReceiveSender interface {
	Receiver
	Sender
}

func Devnull

func Devnull() ReceiveSender

type Receiver

type Receiver interface {
	Receive() ([]byte, *os.File, error)
}

type Route

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

func (*Route) All

func (r *Route) All() *Route

func (*Route) Filter

func (r *Route) Filter(f func([]byte, *os.File) bool) *Route

func (*Route) Handle

func (route *Route) Handle(payload []byte, attachment *os.File) error

func (*Route) Handler

func (r *Route) Handler(h func([]byte, *os.File) error) *Route

func (*Route) HasAttachment

func (r *Route) HasAttachment() *Route

func (*Route) KeyEquals

func (r *Route) KeyEquals(k string, full ...string) *Route

func (*Route) KeyExists

func (r *Route) KeyExists(k string) *Route

func (*Route) KeyIncludes

func (r *Route) KeyIncludes(k, v string) *Route

func (*Route) KeyStartsWith

func (r *Route) KeyStartsWith(k string, beginning ...string) *Route

func (*Route) Match

func (route *Route) Match(payload []byte, attachment *os.File) bool

func (*Route) NoKey

func (r *Route) NoKey(k string) *Route

func (*Route) Passthrough

func (r *Route) Passthrough(dst Sender) *Route

func (*Route) Tee

func (route *Route) Tee(dst Sender) *Route

type Router

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

func NewRouter

func NewRouter(sink Sender) *Router

func (*Router) NewRoute

func (r *Router) NewRoute() *Route

func (*Router) Send

func (r *Router) Send(payload []byte, attachment *os.File) (err error)

type SendCloser

type SendCloser interface {
	Sender
	Close() error
}

type Sender

type Sender interface {
	Send([]byte, *os.File) error
}

type UnixConn

type UnixConn struct {
	*net.UnixConn
	// contains filtered or unexported fields
}

func FileConn

func FileConn(f *os.File) (*UnixConn, error)

func ReceiveConn

func ReceiveConn(src Receiver) ([]byte, *UnixConn, error)

func SendConn

func SendConn(dst Sender, data []byte) (conn *UnixConn, err error)

func (*UnixConn) Receive

func (conn *UnixConn) Receive() (rdata []byte, rf *os.File, rerr error)

Receive waits for a new message on conn, and receives its payload and attachment, or an error if any.

If more than 1 file descriptor is sent in the message, they are all closed except for the first, which is the attachment. It is legal for a message to have no attachment or an empty payload.

func (*UnixConn) Send

func (conn *UnixConn) Send(data []byte, f *os.File) error

Send sends a new message on conn with data and f as payload and attachment, respectively. On success, f is closed

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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