...

Package socket

import "github.com/gonitro/nitro/util/socket"
Overview
Index

Overview ▾

Package socket provides a pseudo socket

type Pool

type Pool struct {
    sync.RWMutex
    // contains filtered or unexported fields
}

func NewPool

func NewPool() *Pool

NewPool returns a new socket pool

func (*Pool) Close

func (p *Pool) Close()

Close the pool and delete all the sockets

func (*Pool) Get

func (p *Pool) Get(id string) (*Socket, bool)

func (*Pool) Release

func (p *Pool) Release(s *Socket)

type Socket

Socket is our pseudo socket for network.Socket

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

func New

func New(id string) *Socket

New returns a new pseudo socket which can be used in the place of a network socket. Messages are sent to the socket via Accept and receives from the socket via Process. SetLocal/SetRemote should be called before using the socket.

func (*Socket) Accept

func (s *Socket) Accept(m *network.Message) error

Accept passes a message to the socket which will be processed by the call to Recv

func (*Socket) Close

func (s *Socket) Close() error

Close closes the socket

func (*Socket) Local

func (s *Socket) Local() string

func (*Socket) Process

func (s *Socket) Process(m *network.Message) error

Process takes the next message off the send queue created by a call to Send

func (*Socket) Recv

func (s *Socket) Recv(m *network.Message) error

func (*Socket) Remote

func (s *Socket) Remote() string

func (*Socket) Send

func (s *Socket) Send(m *network.Message) error

func (*Socket) SetLocal

func (s *Socket) SetLocal(l string)

func (*Socket) SetRemote

func (s *Socket) SetRemote(r string)