app

package
v0.0.0-...-8b94866 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2023 License: Unlicense Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NameDefault                    = "Timemore"
	URLDefault                     = "https://github.com/timemore"
	EmailDefault                   = "nop@e-mail.mailer.com"
	NotificationEmailSenderDefault = "no-reply@e-mail.mailer.com"
	TeamNameDefault                = "Time More Team's"
	EnvDefault                     = "dev"
	DefaultTZLocation              = "UTC"
)
View Source
const EnvPrefixDefault = "APP_"

Variables

This section is empty.

Functions

func LoadEnvFiles

func LoadEnvFiles(envVarKeys []string, fileBasePath string) error

func RunServers

func RunServers(servers []ServiceServer)

func SetBuildInfo

func SetBuildInfo(
	revisionID string,
	timestamp string,
)

func TZLocation

func TZLocation() *time.Location

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 Base

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

func (*Base) AddServer

func (appBase *Base) AddServer(srv ServiceServer)

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

func (Base) AppInfo

func (appBase Base) AppInfo() Info

func (Base) InstanceID

func (appBase Base) InstanceID() string

func (*Base) IsAllServersAcceptingClients

func (appBase *Base) IsAllServersAcceptingClients() bool

IsAllServersAcceptingClients checks if every server is accepting clients.

func (*Base) Run

func (appBase *Base) Run()

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

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
	// URL Canonical URL of the app
	URL                     string
	TermsOfServiceURL       string
	PrivacyPolicyURL        string
	Email                   string
	NotificationEmailSender string
	TeamName                string
	Env                     string
	TZLocation              string
	// contains filtered or unexported fields
}

func DefaultInfo

func DefaultInfo() Info

func (Info) TZ

func (appInfo Info) TZ() *time.Location

type ServiceServer

type ServiceServer interface {
	// ServerName returns the name of the server. This is 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