mux

package
v0.0.0-...-bebc87d Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2014 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package mux is a generated protocol buffer package.

It is generated from these files:

mux.proto

It has these top-level messages:

PBProtocolMessage

Index

Constants

This section is empty.

Variables

View Source
var ProtocolID_name = map[int32]string{
	0: "Test",
	1: "Identify",
	2: "Routing",
	3: "Exchange",
}
View Source
var ProtocolID_value = map[string]int32{
	"Test":     0,
	"Identify": 1,
	"Routing":  2,
	"Exchange": 3,
}

Functions

This section is empty.

Types

type Muxer

type Muxer struct {
	// Protocols are the multiplexed services.
	Protocols ProtocolMap

	*msg.Pipe
	// contains filtered or unexported fields
}

Muxer is a simple multiplexor that reads + writes to Incoming and Outgoing channels. It multiplexes various protocols, wrapping and unwrapping data with a ProtocolID.

func NewMuxer

func NewMuxer(mp ProtocolMap) *Muxer

NewMuxer constructs a muxer given a protocol map.

func (*Muxer) AddProtocol

func (m *Muxer) AddProtocol(p Protocol, pid ProtocolID) error

AddProtocol adds a Protocol with given ProtocolID to the Muxer.

func (*Muxer) GetPipe

func (m *Muxer) GetPipe() *msg.Pipe

GetPipe implements the Protocol interface

func (*Muxer) Start

func (m *Muxer) Start(ctx context.Context) error

Start kicks off the Muxer goroutines.

func (*Muxer) Stop

func (m *Muxer) Stop()

Stop stops muxer activity.

type PBProtocolMessage

type PBProtocolMessage struct {
	ProtocolID       *ProtocolID `protobuf:"varint,1,req,enum=mux.ProtocolID" json:"ProtocolID,omitempty"`
	Data             []byte      `protobuf:"bytes,2,req" json:"Data,omitempty"`
	XXX_unrecognized []byte      `json:"-"`
}

func (*PBProtocolMessage) GetData

func (m *PBProtocolMessage) GetData() []byte

func (*PBProtocolMessage) GetProtocolID

func (m *PBProtocolMessage) GetProtocolID() ProtocolID

func (*PBProtocolMessage) ProtoMessage

func (*PBProtocolMessage) ProtoMessage()

func (*PBProtocolMessage) Reset

func (m *PBProtocolMessage) Reset()

func (*PBProtocolMessage) String

func (m *PBProtocolMessage) String() string

type Protocol

type Protocol interface {
	GetPipe() *msg.Pipe
}

Protocol objects produce + consume raw data. They are added to the Muxer with a ProtocolID, which is added to outgoing payloads. Muxer properly encapsulates and decapsulates when interfacing with its Protocols. The Protocols do not encounter their ProtocolID.

type ProtocolID

type ProtocolID int32
const (
	ProtocolID_Test     ProtocolID = 0
	ProtocolID_Identify ProtocolID = 1
	ProtocolID_Routing  ProtocolID = 2
	ProtocolID_Exchange ProtocolID = 3
)

func (ProtocolID) Enum

func (x ProtocolID) Enum() *ProtocolID

func (ProtocolID) String

func (x ProtocolID) String() string

func (*ProtocolID) UnmarshalJSON

func (x *ProtocolID) UnmarshalJSON(data []byte) error

type ProtocolMap

type ProtocolMap map[ProtocolID]Protocol

ProtocolMap maps ProtocolIDs to Protocols.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳