gowb

package module
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2020 License: BSD-2-Clause Imports: 24 Imported by: 0

README

gowb

Documentation

Index

Constants

View Source
const (
	ArgumentTypeString = "string"
	ArgumentTypeInt    = "int"
	ArgumentTypeUint   = "uint"
	ArgumentTypeBool   = "bool"
)
View Source
const (
	CommandPrefix   = "-"
	CommandAssignee = "="
)
View Source
const (
	LogLevelDebug = 1 << iota
	LogLevelInfo
	LogLevelWarn
	LogLevelErr
)
View Source
const (
	CommandSessionHost = "localhost"
	CommandSessionType = "tcp"
)

Variables

This section is empty.

Functions

func NewMiddlewareCollection

func NewMiddlewareCollection(config Config, app Application, maxLogBodySize int64) *middlewareCollection

New Middleware Collection Init Method

Types

type App

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

func (App) FatalError

func (a App) FatalError(err error)

Fatal error

func (App) GetAbsolutePath

func (a App) GetAbsolutePath(path string, dir string) (string, goerr.IError)

Get absolute path to application

func (App) GetConfig

func (a App) GetConfig() interface{}

Get config struct

func (App) GetConfigPath

func (a App) GetConfigPath(env string) string

Get full path to config

func (*App) GetLogger

func (a *App) GetLogger(level int) Logger

Get logger

func (*App) ParseConfig

func (a *App) ParseConfig(env string) Application

Config parser

func (App) ParseFlags

func (a App) ParseFlags(args *Arguments)

Parse console arguments

func (*App) SetConfig

func (a *App) SetConfig(cfg interface{}) Application

Set config struct

func (App) Start

func (a App) Start(port string, callback func(command Command)) goerr.IError

Start application

type Application

type Application interface {
	// Get config struct
	GetConfig() interface{}
	// Get full path to config
	GetConfigPath(env string) string
	// Get absolute path
	GetAbsolutePath(path string, dir string) (string, goerr.IError)
	// Set config struct
	SetConfig(cfg interface{}) Application
	// Parse config
	ParseConfig(env string) Application
	// Start application
	Start(port string, callback func(command Command)) goerr.IError
	// Behaviour for fatal errors
	FatalError(err error)
	// Get Logger
	GetLogger(level int) Logger
	// Parse console flags
	ParseFlags(args *Arguments)
}

Application class

func NewStdApplication

func NewStdApplication(env string, configPath string, values interface{}) Application

type Argument

type Argument struct {
	Type  string
	Value interface{}
	Label string
	Name  string
}

func (Argument) GetBool

func (a Argument) GetBool() bool

func (Argument) GetInt

func (a Argument) GetInt() int64

func (Argument) GetString

func (a Argument) GetString() string

func (Argument) GetUnit

func (a Argument) GetUnit() uint64

type Arguments

type Arguments map[string]Argument

type BindingIdentifier

type BindingIdentifier interface{}

type Command

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

Command is an argument list

func ParseCommand

func ParseCommand(command []byte) Command

Parse command

func (Command) Arguments

func (c Command) Arguments() []Argument

UnBind connection

func (*Command) BindConnection

func (c *Command) BindConnection(conn net.Conn)

Bind connection to command

func (Command) GetOrigin

func (c Command) GetOrigin() string

Get origin command

func (Command) Result

func (c Command) Result(result []byte) goerr.IError

Result of command to connection

func (Command) String

func (c Command) String() string

Render command

func (*Command) UnbindConnection

func (c *Command) UnbindConnection()

UnBind connection

type Config

type Config struct {
	Port    int
	Host    string
	Url     string
	Timeout struct {
		Read  int
		Write int
		Idle  int
	}
}

type ConnectionBindings

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

func NewConnectionBindings

func NewConnectionBindings() *ConnectionBindings

func (*ConnectionBindings) Bind

func (*ConnectionBindings) GetBindingId

func (*ConnectionBindings) GetConnectionId

func (*ConnectionBindings) UnBind

type ConnectionEvent

type ConnectionEvent struct {
	Name ConnectionEventName
	Done chan bool
}

type ConnectionEventListeners

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

func NewConnectionEventListeners

func NewConnectionEventListeners() *ConnectionEventListeners

New Connection event Listener

func (*ConnectionEventListeners) Dispatch

Dispatch event

func (*ConnectionEventListeners) Get

Get events

func (*ConnectionEventListeners) Register

Register connection listener

func (*ConnectionEventListeners) Unregister

Unregister connection event listener

func (*ConnectionEventListeners) UnregisterConnection

Unregister connection listener

type ConnectionEventName

type ConnectionEventName string

type ConnectionIdentifier

type ConnectionIdentifier string

type Connections

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

func NewConnections

func NewConnections() *Connections

Init tcp connection pool

func (*Connections) Get

Get connection if exists

func (*Connections) Len

func (cs *Connections) Len() int

Connections len

func (*Connections) Set

Set connection

func (*Connections) Unset

Unset connection if exists

type Logger

type Logger interface {
	GetLevel() int

	Print(v ...interface{})
	Println(v ...interface{})
	Printf(format string, v ...interface{})

	Info(v ...interface{})
	Infoln(v ...interface{})
	Infof(format string, v ...interface{})

	Warn(v ...interface{})
	Warnln(v ...interface{})
	Warnf(format string, v ...interface{})

	Error(v ...interface{})
	Errorln(v ...interface{})
	Errorf(format string, v ...interface{})
}

func NewLogger

func NewLogger(level int, prefix string, flags int) Logger

type WebApp

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

func NewApplication

func NewApplication(config Config, app Application, connState func(net.Conn, http.ConnState)) *WebApp

Init Web Application

func (*WebApp) Listen

func (a *WebApp) Listen(routes http.Handler)

Make server and listen

Jump to

Keyboard shortcuts

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