port

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2019 License: Apache-2.0, Apache-2.0 Imports: 2 Imported by: 4

Documentation

Index

Constants

View Source
const (
	LocalInPortId   = 0 //Local InPort ID, receive the message from local
	RemoteInPortId  = 1 //Remote InPort ID, receive the message from remote
	LocalOutPortId  = 0 //Local OutPort ID
	RemoteOutPortId = 1 //Remote OutPort ID
)

common const value

Variables

This section is empty.

Functions

This section is empty.

Types

type InPort

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

InPort is switch in port. Message will be send to InPort, and then switch Read the message from InPort

func NewInPort

func NewInPort(id int) *InPort

create a new in port instance

func (*InPort) Channel

func (inPort *InPort) Channel() chan<- interface{}

Channel return the input channel of this InPort

func (*InPort) PortId

func (inPort *InPort) PortId() int

PortId return this port's id

func (*InPort) Read

func (inPort *InPort) Read() <-chan interface{}

Read message from this InPort, will be blocked until the message arrives.

type OutPort

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

InPort is switch out port. Switch will broadcast message to out port

func NewOutPort

func NewOutPort(id int) *OutPort

create a new out port instance

func (*OutPort) BindToPort

func (outPort *OutPort) BindToPort(outPutFunc OutPutFunc) error

BindToPort bind a new OutPutFunc to this OutPort. Return error if bind failed

func (*OutPort) PortId

func (outPort *OutPort) PortId() int

PortId return this port's id

func (*OutPort) Write

func (outPort *OutPort) Write(msg interface{}) error

Write message to this OutPort

type OutPutFunc

type OutPutFunc func(msg interface{}) error

OutPutFunc is binded to switch out port, and OutPort will call OutPutFunc when receive a message from switch

Jump to

Keyboard shortcuts

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