2015-09-12 20:11:54 +00:00
|
|
|
package core
|
|
|
|
|
2015-09-14 11:51:30 +00:00
|
|
|
const (
|
2015-09-14 16:19:17 +00:00
|
|
|
bufferSize = 16
|
2015-09-14 11:51:30 +00:00
|
|
|
)
|
|
|
|
|
2015-09-22 12:45:03 +00:00
|
|
|
// Ray is an internal tranport channel bewteen inbound and outbound connection.
|
2015-09-12 20:11:54 +00:00
|
|
|
type Ray struct {
|
|
|
|
Input chan []byte
|
|
|
|
Output chan []byte
|
|
|
|
}
|
|
|
|
|
2015-09-22 12:45:03 +00:00
|
|
|
func NewRay() *Ray {
|
|
|
|
return &Ray{
|
2015-09-16 15:07:05 +00:00
|
|
|
Input: make(chan []byte, bufferSize),
|
|
|
|
Output: make(chan []byte, bufferSize),
|
|
|
|
}
|
2015-09-12 20:11:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type OutboundRay interface {
|
|
|
|
OutboundInput() <-chan []byte
|
|
|
|
OutboundOutput() chan<- []byte
|
|
|
|
}
|
|
|
|
|
|
|
|
type InboundRay interface {
|
|
|
|
InboundInput() chan<- []byte
|
|
|
|
InboundOutput() <-chan []byte
|
|
|
|
}
|
|
|
|
|
2015-09-22 12:45:03 +00:00
|
|
|
func (ray *Ray) OutboundInput() <-chan []byte {
|
2015-09-12 20:11:54 +00:00
|
|
|
return ray.Input
|
|
|
|
}
|
|
|
|
|
2015-09-22 12:45:03 +00:00
|
|
|
func (ray *Ray) OutboundOutput() chan<- []byte {
|
2015-09-12 20:11:54 +00:00
|
|
|
return ray.Output
|
|
|
|
}
|
|
|
|
|
2015-09-22 12:45:03 +00:00
|
|
|
func (ray *Ray) InboundInput() chan<- []byte {
|
2015-09-12 20:11:54 +00:00
|
|
|
return ray.Input
|
|
|
|
}
|
|
|
|
|
2015-09-22 12:45:03 +00:00
|
|
|
func (ray *Ray) InboundOutput() <-chan []byte {
|
2015-09-12 20:11:54 +00:00
|
|
|
return ray.Output
|
|
|
|
}
|