app

package
v0.0.0-...-db8c6ed Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2021 License: MIT Imports: 14 Imported by: 7

Documentation

Index

Constants

View Source
const (
	NameDefault                    = "Kadisoka"
	URLDefault                     = "https://github.com/kadisoka"
	EmailDefault                   = "nop@example.com"
	NotificationEmailSenderDefault = "no-reply@example.com"
	TeamNameDefault                = "Team Kadisoka"
)
View Source
const EnvPrefixDefault = "APP_"

Variables

This section is empty.

Functions

func RunServers

func RunServers(servers []ServiceServer)

func SetBuildInfo

func SetBuildInfo(
	revisionID string,
	timestamp string,
)

Types

type App

type App interface {
	AppInfo() Info
	InstanceID() string

	AddServer(ServiceServer)
	Run()
	IsAllServersAcceptingClients() bool
}

func Init

func Init(info *Info) (App, error)

func InitByEnvDefault

func InitByEnvDefault() (App, error)

type AppBase

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

func (*AppBase) AddServer

func (appBase *AppBase) AddServer(srv ServiceServer)

AddServer adds a server to be run simultaneously. Do NOT call this method after the app has been started.

func (AppBase) AppInfo

func (appBase AppBase) AppInfo() Info

func (AppBase) InstanceID

func (appBase AppBase) InstanceID() string

func (*AppBase) IsAllServersAcceptingClients

func (appBase *AppBase) IsAllServersAcceptingClients() bool

IsAllServersAcceptingClients checks if every server is accepting clients.

func (*AppBase) Run

func (appBase *AppBase) Run()

Run runs all the servers. Do NOT add any new server after this method was called.

func (*AppBase) Servers

func (appBase *AppBase) Servers() []ServiceServer

type BuildInfo

type BuildInfo struct {
	RevisionID string
	Timestamp  string
}

func GetBuildInfo

func GetBuildInfo() BuildInfo

type Info

type Info struct {
	// Name of the app
	Name string
	// Canonical URL of the app
	URL                     string
	TermsOfServiceURL       string
	PrivacyPolicyURL        string
	Email                   string
	NotificationEmailSender string
	TeamName                string
}

func DefaultInfo

func DefaultInfo() Info

type ServiceServer

type ServiceServer interface {
	// ServerName returns the name of the server. This not to be unique.
	ServerName() string

	// Serve starts the server. This method is blocking and won't return
	// until the server is stopped (e.g., through Shutdown).
	Serve() error

	// Shutdown gracefully stops the server.
	Shutdown(ctx context.Context) error

	// IsAcceptingClients returns true if the service is ready to serve clients.
	IsAcceptingClients() bool

	// IsHealthy returns true if the service is considerably healthy.
	IsHealthy() bool
}

ServiceServer abstracts all service servers

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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