sos

package
v2.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2018 License: BSD-3-Clause Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PortNum     = "8000"
	DefHtmlPage = `` /* 649-byte string literal not displayed */

)

Variables

This section is empty.

Functions

func GetListener

func GetListener() (net.Listener, uint, error)

GetListener starts listener on a random port in localhost and returns the listener and the port that the listener is on. Remember to close the listener with:

defer listener.close()

or if it's used in a server, remember to shutdown the server.

func HTMLPath

func HTMLPath(n ...string) string

HTMLPath returns the HTMLPath formed by joining the arguments together. If there are no arguments, it simply returns the HTML root directory.

func RegisterServiceWithSos

func RegisterServiceWithSos(service string, port uint) error

RegisterServiceWithSos tries to register a service with SoS. If an non-nil error is returned, the service needs to exit immediately.

func RegistersNecessaryPatterns

func RegistersNecessaryPatterns(router *mux.Router)

RegistersNecessaryPatterns registers all the necessary patterns needed to make a service becomes a SoS client.

func SetHTMLRoot

func SetHTMLRoot(p ...string)

set htmlRoot var to array of dirs p

func StartServer

func StartServer(service *SosService)

func StartServiceServer

func StartServiceServer(router *mux.Router, serviceName string, listener net.Listener, port uint) error

StartServiceServer establishes registers all necessary patterns to the router passed in, registers the service with SoS using the port passed in, and starts serving the service on the listener passed in. If any of the above step fails, this function will return an error. This function wraps around RegistersNecessaryPatterns, RegisterServiceWithSos, and UnregisterServiceWithSos. If no extenral settings are required, instead of calling each of the above separately, one can call the GetListener function and pass the result into this function to start and serve their HTTP server right away.

func UnregisterServiceWithSos

func UnregisterServiceWithSos(service string) error

UnregisterServiceWithSos makes a request to SoS Server to unregister the service. This function should be called before a service exit.

Types

type GetServiceResJson

type GetServiceResJson struct {
	Port uint
}

type RegisterReqJson

type RegisterReqJson struct {
	Service string
	Port    uint
}

type Registry

type Registry map[string]uint

type SosServer

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

type SosService

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

func NewSosService

func NewSosService() *SosService

func (*SosService) Read

func (s *SosService) Read(serviceName string) (uint, error)

func (*SosService) Register

func (s *SosService) Register(serviceName string, portNum uint) error

func (*SosService) SnapshotRegistry

func (s *SosService) SnapshotRegistry() Registry

func (*SosService) Unregister

func (s *SosService) Unregister(serviceName string)

type UnRegisterReqJson

type UnRegisterReqJson struct {
	ServiceName string
}

Jump to

Keyboard shortcuts

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