transport

package
v0.0.0-...-c937b9e Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2015 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cmd

type Cmd int
const (
	CmdRequest Cmd = iota
	CmdResponse
	CmdError
)

type Extractor

type Extractor interface {
	Extract(obj interface{}) error
}

type Fake

type Fake struct{}

Fake transport helps while developing or for mocking if you don't want to implement all Transport interface methods

func (*Fake) Request

func (t *Fake) Request(ctx context.Context, send, recv interface{}) error

func (*Fake) Serve

func (t *Fake) Serve(ctx context.Context, h Handler) error

type Handler

type Handler interface {
	Handle(context.Context, Extractor) (interface{}, error)
}

func Handle

func Handle(f func(context.Context, Extractor) (interface{}, error)) Handler

type LoopTransport

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

func (*LoopTransport) Request

func (s *LoopTransport) Request(ctx context.Context, send, recv interface{}) error

func (*LoopTransport) Serve

func (s *LoopTransport) Serve(ctx context.Context, h Handler) error

type Looper

type Looper interface {
	Loop(ctx context.Context, in chan<- *Message, out <-chan *Message) <-chan error
}

type Message

type Message struct {
	Id   int              `json:"id"`
	Cmd  Cmd              `json:"cmd"`
	Data *json.RawMessage `json:"data"`
}

func NewMessage

func NewMessage(cmd Cmd, obj interface{}) (*Message, error)

func (*Message) Extract

func (m *Message) Extract(obj interface{}) error

func (*Message) GetData

func (m *Message) GetData(obj interface{}) error

func (*Message) SetData

func (m *Message) SetData(obj interface{}) error

type Session

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

func NewSession

func NewSession() *Session

func (*Session) Add

func (s *Session) Add(id int) <-chan *Message

func (*Session) Pick

func (s *Session) Pick(id int) chan<- *Message

type Transport

type Transport interface {
	Serve(ctx context.Context, h Handler) error
	Request(ctx context.Context, send, recv interface{}) error
}

Transport interface

func NewLoopTransport

func NewLoopTransport(loop Looper) Transport

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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