server

package
v0.0.0-...-7b8267f Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

type Command struct {
	Type CommandType `json:"type"`
	Body string      `json:"body"`
}

type CommandHandler

type CommandHandler func(command Command) error

type CommandType

type CommandType string
const (
	CommandPublish CommandType = "publish"
	CommandConsume CommandType = "consume"
	CommandClose   CommandType = "close"
)

type DefaultTcpListener

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

func NewDefaultTcpListener

func NewDefaultTcpListener(config settings.Settings) (*DefaultTcpListener, error)

func (*DefaultTcpListener) Accept

func (t *DefaultTcpListener) Accept(deadline time.Time) (InternalReader, *TcpAcceptError)

func (*DefaultTcpListener) Close

func (t *DefaultTcpListener) Close() error

type DefaultTpcReader

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

func (*DefaultTpcReader) Close

func (t *DefaultTpcReader) Close() error

func (*DefaultTpcReader) Reader

func (t *DefaultTpcReader) Reader() io.Reader

func (*DefaultTpcReader) SetKeepAlive

func (t *DefaultTpcReader) SetKeepAlive(keepalive bool) error

type HttpServer

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

func NewHttpServer

func NewHttpServer(producer producer.Producer, server *http.Server) (*HttpServer, error)

func (*HttpServer) Cancel

func (t *HttpServer) Cancel()

func (*HttpServer) CommandHandlers

func (t *HttpServer) CommandHandlers() map[CommandType]CommandHandler

func (*HttpServer) Start

func (t *HttpServer) Start()

type InternalReader

type InternalReader interface {
	SetKeepAlive(keepalive bool) error
	Close() error
	Reader() io.Reader
}

type InternalTcpListener

type InternalTcpListener interface {
	Close() error
	Accept(deadline time.Time) (InternalReader, *TcpAcceptError)
}

type JsonResponse

type JsonResponse struct {
	Error   bool        `json:"error"`
	Message string      `json:"message"`
	Data    interface{} `json:"data,omitempty"`
}

type MockHttpServer

type MockHttpServer struct {
	Actions map[string]int
	// contains filtered or unexported fields
}

func NewMockHttpServer

func NewMockHttpServer(producer producer.Producer, commands []Command) (*MockHttpServer, error)

func (*MockHttpServer) Cancel

func (t *MockHttpServer) Cancel()

func (*MockHttpServer) CommandHandlers

func (t *MockHttpServer) CommandHandlers() map[CommandType]CommandHandler

func (*MockHttpServer) Start

func (t *MockHttpServer) Start()

type MockReader

type MockReader struct {
	Actions map[string]int
	// contains filtered or unexported fields
}

func NewMockReader

func NewMockReader(lines ...string) *MockReader

func (*MockReader) Close

func (t *MockReader) Close() error

func (*MockReader) Reader

func (t *MockReader) Reader() io.Reader

func (*MockReader) SetKeepAlive

func (t *MockReader) SetKeepAlive(keepalive bool) error

type MockTcpListener

type MockTcpListener struct {
	Actions map[string]int
	// contains filtered or unexported fields
}

func NewMockTcpListener

func NewMockTcpListener(lines ...string) *MockTcpListener

func (*MockTcpListener) Accept

func (t *MockTcpListener) Accept(deadline time.Time) (InternalReader, error)

func (*MockTcpListener) Close

func (t *MockTcpListener) Close() error

type PublishPayload

type PublishPayload struct {
	Type string `json:"type"`
	Data string `json:"data"`
}

type Server

type Server interface {
	Start()
	Cancel()
	CommandHandlers() map[CommandType]CommandHandler
}

type TcpAcceptError

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

func (*TcpAcceptError) Error

func (i *TcpAcceptError) Error() string

func (*TcpAcceptError) IsTimeout

func (i *TcpAcceptError) IsTimeout() bool

type TcpServer

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

func NewTCPServer

func NewTCPServer(producer producer.Producer, listener InternalTcpListener, done chan bool) (*TcpServer, error)

func (*TcpServer) Cancel

func (t *TcpServer) Cancel()

func (*TcpServer) CommandHandlers

func (t *TcpServer) CommandHandlers() map[CommandType]CommandHandler

func (*TcpServer) Start

func (t *TcpServer) Start()

Jump to

Keyboard shortcuts

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