socket

package
v0.0.0-...-986d81d Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2018 License: MPL-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package socket contains the structs and logic to create, configure, and maintain multi-queue sockets. Each socket type is represented by a struct adhering to the included socket interface, which describes a generic multi-queue socket.

Currently supported sockets:

  • UDP socket
  • DTLS socket

Index

Constants

View Source
const (
	// UDPSocket type creates and manages a UDP based socket.
	UDPSocket = "udp"

	// DTLSSocket type creates and manages a UDP based socket that is encrypted using DTLS.
	DTLSSocket = "dtls"

	// MOCKSocket type creates and manages a mocked out socket for testing.
	MOCKSocket = "mock"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DTLS

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

DTLS socket struct for managing a multi-queue openssl based DTLS socket.

func (*DTLS) Close

func (dtls *DTLS) Close() error

Close the DTLS socket and removes associated network configuration.

func (*DTLS) Queues

func (dtls *DTLS) Queues() []int

Queues will return the underlying DTLS socket file descriptors.

func (*DTLS) Read

func (dtls *DTLS) Read(queue int, buf []byte) (*common.Payload, bool)

Read a packet off the specified DTLS socket queue and return a *common.Payload representation of the packet.

func (*DTLS) Write

func (dtls *DTLS) Write(queue int, payload *common.Payload, mapping *common.Mapping) bool

Write a *common.Payload to the specified DTLS socket queue.

type Mock

type Mock struct {
}

Mock socket struct to use for testing.

func (*Mock) Close

func (mock *Mock) Close() error

Close which is a noop.

func (*Mock) Queues

func (mock *Mock) Queues() []int

Queues which is a noop.

func (*Mock) Read

func (mock *Mock) Read(queue int, buf []byte) (*common.Payload, bool)

Read which just returns the supplied buffer in the form of a *common.Payload.

func (*Mock) Write

func (mock *Mock) Write(queue int, payload *common.Payload, mapping *common.Mapping) bool

Write which is a noop.

type Socket

type Socket interface {
	// Read should return a formatted *common.Payload, based on the provided byte slice, off the specified socket queue.
	Read(queue int, buf []byte) (*common.Payload, bool)

	// Write should handle being passed a formatted *common.Payload + *common.Mapping, and write the underlying raw data using the specified socket queue.
	Write(queue int, payload *common.Payload, mapping *common.Mapping) bool

	// Close should gracefully destroy the socket.
	Close() error

	// Queues should return all underlying queue file descriptors to pass along during a rolling restart.
	Queues() []int
}

Socket interface for a generic multi-queue socket interface.

func New

func New(socketType string, cfg *common.Config) (Socket, error)

New generates a socket based on the supplied type and configuration.

type UDP

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

UDP socket struct for managing a multi-queue udp socket.

func (*UDP) Close

func (udp *UDP) Close() error

Close the UDP socket and removes associated network configuration.

func (*UDP) Queues

func (udp *UDP) Queues() []int

Queues will return the underlying UDP socket file descriptors.

func (*UDP) Read

func (udp *UDP) Read(queue int, buf []byte) (*common.Payload, bool)

Read a packet off the specified UDP socket queue and return a *common.Payload representation of the packet.

func (*UDP) Write

func (udp *UDP) Write(queue int, payload *common.Payload, mapping *common.Mapping) bool

Write a *common.Payload to the specified UDP socket queue.

Jump to

Keyboard shortcuts

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