servers

package
v0.0.0-...-4c2dc58 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2016 License: MIT Imports: 12 Imported by: 1

README

Golang.hr Platform Server Package

Server package for Golang.hr Platform. This package is designed to act as server adapters that you can use to start up your services.

Design Concept / TODO
  • gRPC Server
  • HTTP Server
  • AMQP Server
  • MQTT Server
License
The MIT License (MIT)

Copyright (c) 2015 Golang Croatia

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Documentation

Overview

Package servers ...

Package servers ...

Package servers ...

Package servers ...

Package servers ...

Package servers ...

Package servers ...

Package servers ...

Package servers ...

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConnectivityState

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

ConnectivityState - Designed to keep track of server current connection state

func (*ConnectivityState) GetCurrentState

func (cs *ConnectivityState) GetCurrentState() int64

GetCurrentState - Will return current state. If state is not set, it will return 0 which equals to state DOWN

func (*ConnectivityState) GetStateByName

func (cs *ConnectivityState) GetStateByName(state string) int64

GetStateByName - Will attempt to figure out state by name. If state is not found it will return 0 which equals to DOWN

func (*ConnectivityState) SetState

func (cs *ConnectivityState) SetState(state string) error

SetState - Will connection state. In case that state is not available it will return error

func (*ConnectivityState) SetStateConnecting

func (cs *ConnectivityState) SetStateConnecting()

SetStateConnecting - Will set current state to CONNECTING

func (*ConnectivityState) SetStateDown

func (cs *ConnectivityState) SetStateDown()

SetStateDown - Will set current state to DOWN

func (*ConnectivityState) SetStateFailed

func (cs *ConnectivityState) SetStateFailed()

SetStateFailed - Will set current state to FAILED

func (*ConnectivityState) SetStateIdle

func (cs *ConnectivityState) SetStateIdle()

SetStateIdle - Will set current state to IDLE

func (*ConnectivityState) SetStateReady

func (cs *ConnectivityState) SetStateReady()

SetStateReady - Will set current state to READY

func (*ConnectivityState) SetStateShutdown

func (cs *ConnectivityState) SetStateShutdown()

SetStateShutdown - Will set current state to SHUTDOWN

func (*ConnectivityState) String

func (cs *ConnectivityState) String() string

String - Will return name of the state. If state cannot be found, empty string will be returned

type Grpc

type Grpc struct {

	// IF grpc fails, it will restart it immediately...
	ListenForever bool

	// ConnectivityState indicates the state of a grpc connection.
	*ConnectivityState

	// Interrupt signals the listener to stop serving connections,
	// and the server to shut down.
	Interrupt chan os.Signal

	options.Options
	net.Listener
	*logging.Entry
	services.Servicer

	*grpc.Server
	// contains filtered or unexported fields
}

Grpc - Wrapper on top of googles grpc.io server

func (*Grpc) Interface

func (g *Grpc) Interface() interface{}

Interface - Will return current server as interface. This is useful in case you need to access portion of the struct that is not acccessibble via interface

func (*Grpc) Restart

func (g *Grpc) Restart() error

Restart - Will initiate full service restart ...

func (*Grpc) Start

func (g *Grpc) Start() error

Start - Proxy on top of grpc.Server with functionallity to auto restart if Grpc.ListenForever is set to be true.

func (*Grpc) State

func (g *Grpc) State() *ConnectivityState

State - indicates the state of a grpc connection.

func (*Grpc) Stop

func (g *Grpc) Stop() error

Stop - Will attempt to stop gRPC server. In case that server is not started we will return error

type GrpcRest

type GrpcRest struct {
	options.Options
	*logging.Entry
	services.Servicer

	// ConnectivityState indicates the state of a http connection.
	*ConnectivityState
	*http.Server

	// ListenForever if set to true will restart it immediately if listening fails
	ListenForever bool

	// Limit the number of outstanding requests
	ListenLimit int

	// TLS Certificate
	TLSCertFile string

	// TLS Key
	TLSKeyFile string

	// Interrupt signals the listener to stop serving connections,
	// and the server to shut down.
	Interrupt chan os.Signal

	// Mutex is used to protect against concurrent calls to Stop
	sync.Mutex
	// contains filtered or unexported fields
}

GrpcRest -

func (*GrpcRest) Interface

func (gr *GrpcRest) Interface() interface{}

Interface -

func (*GrpcRest) Restart

func (gr *GrpcRest) Restart() error

Restart -

func (*GrpcRest) SetHandler

func (gr *GrpcRest) SetHandler(uri string, handler http.Handler)

SetHandler -

func (*GrpcRest) Start

func (gr *GrpcRest) Start() error

Start - Will attempt to start HTTP server depending on actual configuration In case that ListenForever is enabled we are going to try to restart server until server starts In case of interruption we are going to stop http server

func (*GrpcRest) State

func (gr *GrpcRest) State() *ConnectivityState

State - State of the GRPC REST API connection @TODO

func (*GrpcRest) Stop

func (gr *GrpcRest) Stop() error

Stop -

type HTTP

type HTTP struct {
	options.Options
	*logging.Entry
	services.Servicer

	// ConnectivityState indicates the state of a http connection.
	*ConnectivityState
	*http.Server

	// ListenForever if set to true will restart it immediately if listening fails
	ListenForever bool

	// Limit the number of outstanding requests
	ListenLimit int

	TLSCertFile string
	TLSKeyFile  string
	UseTLS      bool

	// Interrupt signals the listener to stop serving connections,
	// and the server to shut down.
	Interrupt chan os.Signal

	// Mutex is used to protect against concurrent calls to Stop
	sync.Mutex
	// contains filtered or unexported fields
}

HTTP -

func (*HTTP) Interface

func (h *HTTP) Interface() interface{}

Interface -

func (*HTTP) Restart

func (h *HTTP) Restart() error

Restart -

func (*HTTP) SetHandler

func (h *HTTP) SetHandler(handler http.Handler)

SetHandler -

func (*HTTP) Start

func (h *HTTP) Start() error

Start - Will attempt to start HTTP server depending on actual configuration In case that ListenForever is enabled we are going to try to restart server until server starts In case of interruption we are going to stop http server

func (*HTTP) State

func (h *HTTP) State() *ConnectivityState

State - State of the HTTP connection @TODO

func (*HTTP) Stop

func (h *HTTP) Stop() error

Stop -

type Serverer

type Serverer interface {
	Start() error
	Stop() error
	Restart() error
	Interface() interface{}
	State() *ConnectivityState
}

Serverer - Global server interface that ALL servers should satisfy

func NewGrpcRestServer

func NewGrpcRestServer(serv services.Servicer, opts options.Options, logger *logging.Entry) (Serverer, error)

NewGrpcRestServer -

func NewGrpcServer

func NewGrpcServer(serv services.Servicer, opts options.Options, logger *logging.Entry) (Serverer, error)

NewGrpcServer -

func NewHTTPServer

func NewHTTPServer(serv services.Servicer, opts options.Options, logger *logging.Entry) (Serverer, error)

NewHTTPServer -

type WebSocket

type WebSocket struct{}

WebSocket -

Jump to

Keyboard shortcuts

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