socket

package
v0.0.0-...-ab49fd9 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Requester        = SocketType("Requester")
	Replier          = SocketType("Replier")
	Publisher        = SocketType("Publisher")
	Subscriber       = SocketType("Subscriber")
	ContextRequester = SocketType("ContextRequester")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

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

func (*Context) Close

func (s *Context) Close() error

Close Closes the underlying socket

func (*Context) Read

func (s *Context) Read() ([]byte, error)

Read recieves bytes from socket. Goes from Recv to Read to match io.ReadWriteCloser interface

func (*Context) Write

func (s *Context) Write(msg []byte) error

Write Sends bytes over socket Goes from Send to Write to match io.ReadWriteCloser interface

type ContextSocket

type ContextSocket interface {
	Get() (ReadWriter, error)
	Close() error
}

func GetContextSocket

func GetContextSocket(ctx context.Context, s *Socket) (ContextSocket, error)

type NanomsgSocket

type NanomsgSocket struct {
	SocketType  SocketType `json:"socket_type"`
	Host        string     `json:"host"`
	Port        int        `json:"port"`
	Dial        bool       `json:"dial"`
	Listen      bool       `json:"listen"`
	RecvTimeout int        `json:"recv_timeout"`
	SendTimeout int        `json:"send_timeout"`
	// contains filtered or unexported fields
}

NanomsgSocket containes a raw mangosSocket that is constructed during connection. Also contains various configuration patterns used for construction

func (*NanomsgSocket) Close

func (s *NanomsgSocket) Close() error

func (*NanomsgSocket) Connect

func (s *NanomsgSocket) Connect() error

Connect creates a socket based on the SocketType. setting timeouts if specified.

func (*NanomsgSocket) Get

func (s *NanomsgSocket) Get() (ReadWriter, error)

OpenContext context socket can be used when duing parallel requests over a socket and wish to get responses back to match the request

type ReadWriter

type ReadWriter interface {
	Reader
	Writer
}

type Reader

type Reader interface {
	Read() ([]byte, error)
	Close() error
}

func GetSubscriberSocket

func GetSubscriberSocket(ctx context.Context, s *Socket) (Reader, error)

type Socket

type Socket struct {
	Type   SocketType `json:"type"`
	Host   string     `json:"host"`
	Port   int        `json:"port"`
	Listen bool       `json:"listen"`
	Dial   bool       `json:"dial"`
}

type SocketType

type SocketType string

type Writer

type Writer interface {
	Write([]byte) error
	Close() error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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