transports

package
v0.0.0-...-da72ffe Latest Latest
Warning

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

Go to latest
Published: May 16, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

pkg/transports/connection.go

pkg/transports/handler.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Connection

type Connection interface {
	// Send sends data to the connection.
	Send(data []byte) error

	SendWithCallback(data []byte, callback gnet.AsyncCallback) error

	// Close closes the connection.
	Close() error

	// RemoteAddr returns the remote address of the connection.
	RemoteAddr() string
}

Connection represents a generic connection interface that transports use to send and receive data.

type Handler

type Handler interface {
	Handle(conn Connection, frame []byte)
}

Handler defines the interface for handling incoming messages.

type HandlerFunc

type HandlerFunc func(conn Connection, frame []byte)

HandlerFunc is a helper to allow functions to be used as handlers.

func (HandlerFunc) Handle

func (f HandlerFunc) Handle(conn Connection, frame []byte)

Handle calls the handler function.

type Manager

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

Manager is responsible for managing different transport servers

func NewManager

func NewManager() *Manager

func (*Manager) DeregisterTransport

func (tm *Manager) DeregisterTransport(tType types.TransportType) error

func (*Manager) GetTransport

func (tm *Manager) GetTransport(tType types.TransportType) (Transport, error)

func (*Manager) GetTransports

func (tm *Manager) GetTransports() map[types.TransportType]Transport

func (*Manager) RegisterTransport

func (tm *Manager) RegisterTransport(tType types.TransportType, transport Transport) error

type TCPReadHandler

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

TCPReadHandler struct with MDBX database passed in

func NewTCPReadHandler

func NewTCPReadHandler(db db.Provider) *TCPReadHandler

NewTCPReadHandler creates a new TCPReadHandler with an MDBX database

func (*TCPReadHandler) Handle

func (rh *TCPReadHandler) Handle(conn Connection, frame []byte)

Handle processes the incoming message using the TCPReadHandler

type TCPWriteHandler

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

TCPWriteHandler struct with MDBX database passed in

func NewTCPWriteHandler

func NewTCPWriteHandler(db db.Provider, batchWriter *db.BatchWriter) *TCPWriteHandler

NewTCPWriteHandler creates a new TCPWriteHandler with an MDBX database

func (*TCPWriteHandler) Handle

func (wh *TCPWriteHandler) Handle(conn Connection, frame []byte)

Handle processes the incoming message using the TCPWriteHandler

type Transport

type Transport interface {
	Addr() string
	Start(ctx context.Context) error
	Stop() error
}

Directories

Path Synopsis
pkg/transports/tcp/connection.go
pkg/transports/tcp/connection.go

Jump to

Keyboard shortcuts

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