mt

package module
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2021 License: Apache-2.0 Imports: 11 Imported by: 2

README

MT

Build Status

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Services map[string]service `json:"services"`
}

Config ...

func ParseConfig

func ParseConfig(jsonConf []byte) (Config, error)

ParseConfig read config from json.

type Handler

type Handler interface {
	Serve(*Request)
}

Handler ...

type Header amqp.Table

A Header represents the key-value pairs in a message header.

func (Header) AddString

func (h Header) AddString(key, value string)

AddString adds the key, string value pair to the header.

func (Header) String

func (h Header) String(key string) string

type Logger

type Logger interface {
	Infof(format string, args ...interface{})
	Errorf(format string, args ...interface{})
	Debugf(format string, args ...interface{})
}

Logger is an interface for logger to pass into mt server.

type MT

type MT interface {
	ConnectAndServe() error
	HandleFunc(serviceName string, handler func(*Request) error)
	Call(serviceName string, request Request, res func(response Response)) error
	Cast(serviceName string, request Request) error
	Shutdown() error
	HealthCheck() bool
}

MT is a interface.

func NewMT

func NewMT(opts ...Option) MT

NewMT get new instance.

type Option

type Option func(*mt)

Option for MT.

func WithAMQP

func WithAMQP(dsn string) Option

WithAMQP use dsn string.

func WithConfig

func WithConfig(config Config) Option

WithConfig set config.

func WithLogger

func WithLogger(log Logger) Option

WithLogger set logger.

type Request

type Request struct {
	Header Header
	Body   []byte
}

Request from chan.

type Response

type Response struct {
	Body []byte
}

Response from chan.

Jump to

Keyboard shortcuts

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