Documentation ¶
Index ¶
- Constants
- func GetListener() (net.Listener, uint, error)
- func HTMLPath(n ...string) string
- func RegisterServiceWithSos(service string, port uint) error
- func RegistersNecessaryPatterns(router *mux.Router)
- func SetHTMLRoot(p ...string)
- func StartServer(service *SosService)
- func StartServiceServer(router *mux.Router, serviceName string, listener net.Listener, port uint) error
- func UnregisterServiceWithSos(service string) error
- type GetServiceResJson
- type RegisterReqJson
- type Registry
- type SosServer
- type SosService
- type UnRegisterReqJson
Constants ¶
const ( PortNum = "8000" DefHtmlPage = `` /* 649-byte string literal not displayed */ )
Variables ¶
This section is empty.
Functions ¶
func GetListener ¶
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 ¶
HTMLPath returns the HTMLPath formed by joining the arguments together. If there are no arguments, it simply returns the HTML root directory.
func RegisterServiceWithSos ¶
RegisterServiceWithSos tries to register a service with SoS. If an non-nil error is returned, the service needs to exit immediately.
func RegistersNecessaryPatterns ¶
RegistersNecessaryPatterns registers all the necessary patterns needed to make a service becomes a SoS client.
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 ¶
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 SosService ¶
type SosService struct {
// contains filtered or unexported fields
}
func NewSosService ¶
func NewSosService() *SosService
func (*SosService) SnapshotRegistry ¶
func (s *SosService) SnapshotRegistry() Registry
func (*SosService) Unregister ¶
func (s *SosService) Unregister(serviceName string)
type UnRegisterReqJson ¶
type UnRegisterReqJson struct {
ServiceName string
}