sauce

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2023 License: Apache-2.0 Imports: 22 Imported by: 9

README

sauce

Abstract API for Server Application Frameworks

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	LogClass        = reflect.TypeOf((*zap.Logger)(nil))        // *zap.Logger
	LumberjackClass = reflect.TypeOf((*lumberjack.Logger)(nil)) // *lumberjack.Logger

	FileSystemClass = reflect.TypeOf((*http.FileSystem)(nil)).Elem() // http.FileSystem
	FlagSetClass    = reflect.TypeOf((*flag.FlagSet)(nil))           // *flag.FlagSet
)
View Source
var (
	TlsConfigClass       = reflect.TypeOf((*tls.Config)(nil))       // *tls.Config
	AutocertManagerClass = reflect.TypeOf((*autocert.Manager)(nil)) // *autocert.Manager

	GrpcServerClass    = reflect.TypeOf((*grpc.Server)(nil))   // *grpc.Server
	HealthCheckerClass = reflect.TypeOf((*health.Server)(nil)) // *health.Server
	HttpServerClass    = reflect.TypeOf((*http.Server)(nil))   // *http.Server
)
View Source
var ApplicationClass = reflect.TypeOf((*Application)(nil)).Elem()
View Source
var ApplicationFlagsClass = reflect.TypeOf((*ApplicationFlags)(nil)).Elem()
View Source
var AuthenticationServiceClass = reflect.TypeOf((*AuthorizationMiddleware)(nil)).Elem()
View Source
var AutocertStorageClass = reflect.TypeOf((*AutocertStorage)(nil)).Elem()
View Source
var AutoupdateServiceClass = reflect.TypeOf((*AutoupdateService)(nil)).Elem()
View Source
var CertificateIssuerClass = reflect.TypeOf((*CertificateIssuer)(nil)).Elem()
View Source
var CertificateIssuerServiceClass = reflect.TypeOf((*CertificateIssueService)(nil)).Elem()
View Source
var CertificateManagerClass = reflect.TypeOf((*CertificateManager)(nil)).Elem()
View Source
var CertificateRepositoryClass = reflect.TypeOf((*CertificateRepository)(nil)).Elem()
View Source
var CertificateServiceClass = reflect.TypeOf((*CertificateService)(nil)).Elem()
View Source
var ClientScannerClass = reflect.TypeOf((*ClientScanner)(nil)).Elem()
View Source
var CommandClass = reflect.TypeOf((*Command)(nil)).Elem()
View Source
var ComponentClass = reflect.TypeOf((*Component)(nil)).Elem()

* Generic component class that has a name

View Source
var ConfigRepositoryClass = reflect.TypeOf((*ConfigRepository)(nil)).Elem()
View Source
var ControlClientClass = reflect.TypeOf((*ControlClient)(nil)).Elem()
View Source
var CoreScannerClass = reflect.TypeOf((*CoreScanner)(nil)).Elem()
View Source
var DNSProviderClass = reflect.TypeOf((*DNSProvider)(nil)).Elem()
View Source
var DNSProviderClientClass = reflect.TypeOf((*DNSProviderClient)(nil)).Elem()
View Source
var DynDNSServiceClass = reflect.TypeOf((*DynDNSService)(nil)).Elem()
View Source
var FlagSetRegistrarClass = reflect.TypeOf((*FlagSetRegistrar)(nil)).Elem()
View Source
var GrpcClientClass = reflect.TypeOf((*grpc.ClientConn)(nil)) // *grpc.ClientConn
View Source
var JobServiceClass = reflect.TypeOf((*JobService)(nil)).Elem()
View Source
var MailServiceClass = reflect.TypeOf((*MailService)(nil)).Elem()
View Source
var NatServiceClass = reflect.TypeOf((*NatService)(nil)).Elem()
View Source
var NodeServiceClass = reflect.TypeOf((*NodeService)(nil)).Elem()
View Source
var PageClass = reflect.TypeOf((*Page)(nil)).Elem()
View Source
var ResourceServiceClass = reflect.TypeOf((*ResourceService)(nil)).Elem()
View Source
var ServerClass = reflect.TypeOf((*Server)(nil)).Elem()
View Source
var ServerScannerClass = reflect.TypeOf((*ServerScanner)(nil)).Elem()
View Source
var StorageServiceClass = reflect.TypeOf((*StorageService)(nil)).Elem()
View Source
var SystemEnvironmentPropertyResolverClass = reflect.TypeOf((*SystemEnvironmentPropertyResolver)(nil)).Elem()
View Source
var WhoisServiceClass = reflect.TypeOf((*WhoisService)(nil)).Elem()

Functions

This section is empty.

Types

type AcmeAccount

type AcmeAccount struct {
	Status                 string          `json:"status,omitempty"`
	Contact                []string        `json:"contact,omitempty"`
	TermsOfServiceAgreed   bool            `json:"termsOfServiceAgreed,omitempty"`
	Orders                 string          `json:"orders,omitempty"`
	OnlyReturnExisting     bool            `json:"onlyReturnExisting,omitempty"`
	ExternalAccountBinding json.RawMessage `json:"externalAccountBinding,omitempty"`
}

type AcmeResource

type AcmeResource struct {
	Body AcmeAccount `json:"body,omitempty"`
	URI  string      `json:"uri,omitempty"`
}

type AcmeUser

type AcmeUser struct {
	Email        string
	Registration *AcmeResource
	PrivateKey   crypto.PrivateKey
}

type Application

type Application interface {
	context.Context
	gluten.InitializingBean
	gluten.NamedBean
	Component

	/**
	Add beans to application context
	*/
	AppendBeans(beans ...interface{})

	/**
	Gets application name, represents lower case normalized executable name
	*/
	Name() string

	/**
	Gets application version at the time of compilation
	*/
	Version() string

	/**
	Gets application build at the time of compilation
	*/
	Build() string

	/**
	Gets application runtime profile, could be: dev, qa, prod and etc.
	*/
	Profile() string

	/**
	Checks if application running in dev mode
	*/
	IsDev() bool

	/**
	Gets application binary name, used on startup, could be different with application name
	*/
	Executable() string

	/**
	Gets home directory of the application, usually parent directory of binary folder where executable is running, not current directory
	*/
	ApplicationDir() string

	/**
	Run application with command line arguments
	*/
	Run(args []string) error

	/**
	Indicator if application is active and not in shutting down mode
	*/
	Active() bool

	/**
	Sets the flag that application is in shutting down mode then notify all go routines by ShutdownChannel then notify signal channel with interrupt signal

	Additionally sets the flag that application is going to be restarted after shutdown
	*/
	Shutdown(restart bool)

	/**
	Indicator if application needs to be restarted by autoupdate or remote command after shutdown
	*/
	Restarting() bool
}

*

Application is the base entry point class for golang application.

type ApplicationFlags

type ApplicationFlags interface {
	gluten.PropertyResolver

	Daemon() bool

	Verbose() bool

	Properties() map[string]string
}

type AuthorizationMiddleware

type AuthorizationMiddleware interface {
	gluten.InitializingBean

	Authenticate(ctx context.Context) (context.Context, error)

	GetUser(ctx context.Context) (*AuthorizedUser, bool)

	HasUserRole(ctx context.Context, role string) bool

	UserContext(ctx context.Context, name string) (string, bool)

	GenerateToken(user *AuthorizedUser) (string, error)

	ParseToken(token string) (*AuthorizedUser, error)

	InvalidateToken(token string)
}

type AuthorizedUser

type AuthorizedUser struct {
	Username  string
	Roles     map[string]bool
	Context   map[string]string
	ExpiresAt int64
	Token     string
}

type AutocertStorage

type AutocertStorage interface {
	Cache(serverName string) autocert.Cache
}

type AutoupdateService

type AutoupdateService interface {
	gluten.InitializingBean
	gluten.DisposableBean

	Freeze(jobName string) int64

	Unfreeze(handle int64)

	FreezeJobs() map[int64]string
}

type CertificateDesc

type CertificateDesc struct {
	Organization string
	Country      string
	Province     string
	City         string
	Street       string
	Zip          string
}

type CertificateIssueService

type CertificateIssueService interface {
	LoadCertificateDesc() (*CertificateDesc, error)

	CreateIssuer(cn string, info *CertificateDesc) (CertificateIssuer, error)

	LoadIssuer(*saucepb.SelfSigner) (CertificateIssuer, error)

	LocalIPAddresses(addLocalhost bool) ([]net.IP, error)
}

type CertificateIssuer

type CertificateIssuer interface {
	Parent() (CertificateIssuer, bool)

	Certificate() IssuedCertificate

	IssueInterCert(cn string) (CertificateIssuer, error)

	IssueClientCert(cn string, password string) (cert IssuedCertificate, pfxData []byte, err error)

	IssueServerCert(cn string, domains []string, ipAddresses []net.IP) (IssuedCertificate, error)
}

type CertificateManager

type CertificateManager interface {
	gluten.InitializingBean
	gluten.DisposableBean

	GetCertificate(hello *tls.ClientHelloInfo) (*tls.Certificate, error)

	InvalidateCache(domain string)

	ListActive() map[string]error

	ListRenewal() map[string]time.Time

	ListUnknown() map[string]time.Time

	ExecuteCommand(cmd string, args []string) (string, error)
}

type CertificateRepository

type CertificateRepository interface {
	gluten.DisposableBean

	/**
	Self Signer CRUID
	*/
	SaveSelfSigner(self *saucepb.SelfSigner) error

	FindSelfSigner(name string) (*saucepb.SelfSigner, error)

	ListSelfSigners(prefix string, cb func(*saucepb.SelfSigner) bool) error

	DeleteSelfSigner(name string) error

	/**
	Acme Account CRUID
	*/
	SaveAccount(account *saucepb.AcmeAccount) error

	FindAccount(email string) (*saucepb.AcmeAccount, error)

	ListAccounts(prefix string, cb func(*saucepb.AcmeAccount) bool) error

	DeleteAccount(email string) error

	SaveZone(zone *saucepb.Zone) error

	FindZone(zone string) (*saucepb.Zone, error)

	ListZones(prefix string, cb func(*saucepb.Zone) bool) error

	DeleteZone(zone string) error

	Watch(ctx context.Context, cb func(zone, event string) bool) (cancel context.CancelFunc, err error)

	Backend() fastfood.DataStore

	/**
	Sets backend using for storing certificates
	*/
	SetBackend(storage fastfood.DataStore)
}

type CertificateService

type CertificateService interface {
	gluten.InitializingBean

	CreateAcmeAccount(email string) error

	GetOrCreateAcmeUser(email string) (user *AcmeUser, err error)

	CreateSelfSigner(cn string, withInter bool) error

	RenewCertificate(zone string) error

	ExecuteCommand(cmd string, args []string) (string, error)

	IssueAcmeCertificate(entry *saucepb.Zone) (string, error)

	IssueSelfSignedCertificate(entry *saucepb.Zone) error
}

type ClientScanner

type ClientScanner interface {
	ClientBeans() []interface{}
}

type Command

type Command interface {
	gluten.NamedBean

	Run(args []string) error

	Desc() string
}

type Component

type Component interface {
	gluten.NamedBean

	GetStats(cb func(name, value string) bool) error
}

type ConfigRepository

type ConfigRepository interface {
	gluten.DisposableBean
	gluten.PropertyResolver

	Get(key string) (string, error)

	EnumerateAll(prefix string, cb func(key, value string) bool) error

	Set(key, value string) error

	Watch(context context.Context, prefix string, cb func(key, value string) bool) (context.CancelFunc, error)

	Backend() fastfood.DataStore

	/**
	Sets backend using for storing properties
	*/
	SetBackend(storage fastfood.DataStore)
}

type ControlClient

type ControlClient interface {
	gluten.InitializingBean
	gluten.DisposableBean

	Status() (string, error)

	Shutdown(restart bool) (string, error)

	ConfigCommand(command string, args []string) (string, error)

	CertificateCommand(command string, args []string) (string, error)

	JobCommand(command string, args []string) (string, error)

	StorageCommand(command string, args []string) (string, error)

	StorageConsole(writer io.StringWriter, errWriter io.StringWriter) error
}

type CoreScanner

type CoreScanner interface {

	/**
	Gets core beans that will extend application beans, parent context.
	*/
	CoreBeans() []interface{}
}

*

Core scanner is using to find beans to create core context when application is already created.

type DNSProvider

type DNSProvider interface {
	gluten.NamedBean

	Detect(whois *Whois) bool

	RegisterChallenge(legoClient interface{}, token string) error

	NewClient() (DNSProviderClient, error)
}

type DNSProviderClient

type DNSProviderClient interface {
	GetPublicIP() (addr string, err error)

	GetRecords(zoneID string) ([]*DNSRecord, error)

	CreateRecord(zoneID string, record *DNSRecord) (*DNSRecord, error)

	RemoveRecord(zoneID, recordID string) error
}

type DNSRecord

type DNSRecord struct {
	ID       string `json:"id,omitempty"`
	Hostname string `json:"hostname,omitempty"`
	TTL      int    `json:"ttl,omitempty"`
	Type     string `json:"type,omitempty"`
	Priority int    `json:"priority,omitempty"`
	Value    string `json:"value,omitempty"`
}

DNSRecord DNS record representation.

type DynDNSService

type DynDNSService interface {
	gluten.NamedBean
	gluten.InitializingBean

	EnsureAllPublic(subDomains ...string) error

	EnsureCustom(func(client DNSProviderClient, zone string, externalIP string) error) error
}

type FlagSetRegistrar

type FlagSetRegistrar interface {
	RegisterFlags(fs *flag.FlagSet)

	RegisterServerArgs(args []string) []string
}

type IssuedCertificate

type IssuedCertificate interface {
	KeyFileContents() []byte

	CertFileContents() []byte

	PrivateKey() crypto.Signer

	Certificate() *x509.Certificate
}

type JobInfo

type JobInfo struct {
	Name        string
	Schedule    string
	ExecutionFn func(context.Context) error
}

type JobService

type JobService interface {
	ListJobs() ([]string, error)

	AddJob(*JobInfo) error

	CancelJob(name string) error

	RunJob(ctx context.Context, name string) error

	ExecuteCommand(cmd string, args []string) (string, error)
}

type Mail

type Mail struct {
	Sender       string
	Recipients   []string
	Subject      string
	TextTemplate string
	HtmlTemplate string // optional
	Data         interface{}
	Attachments  []string // optional
}

type MailService

type MailService interface {
	gluten.NamedBean

	SendMail(mail *Mail, timeout time.Duration, async bool) error
}

type NatService

type NatService interface {
	AllowMapping() bool

	AddMapping(protocol string, extport, intport int, name string, lifetime time.Duration) error

	DeleteMapping(protocol string, extport, intport int) error

	ExternalIP() (net.IP, error)

	ServiceName() string
}

type NodeService

type NodeService interface {
	gluten.InitializingBean
	Component

	NodeId() uint64

	NodeIdHex() string

	Issue() uuid.UUID

	Parse(uuid.UUID) (timestampMillis int64, nodeId int64, clock int)
}

type Page

type Page interface {
	http.Handler

	Pattern() string
}

type Record

type Record struct {
	Key   []byte
	Value []byte
}

type ResourceService

type ResourceService interface {
	GetResource(name string) ([]byte, error)

	TextTemplate(name string) (*textTemplate.Template, error)

	HtmlTemplate(name string) (*htmlTemplate.Template, error)

	GetLicenses(name string) (string, error)

	GetOpenAPI(source string) string
}

type Server

type Server interface {
	gluten.InitializingBean
	gluten.DisposableBean

	Bind() error

	Active() bool

	ListenAddress() net.Addr

	Serve() error

	Stop()
}

type ServerScanner

type ServerScanner interface {
	ServerBeans() []interface{}
}

type StorageConsoleStream

type StorageConsoleStream interface {
	Send(*saucepb.StorageConsoleResponse) error

	Recv() (*saucepb.StorageConsoleRequest, error)
}

type StorageService

type StorageService interface {
	gluten.InitializingBean

	Execute(name, query string, cb func(string) bool) error

	ExecuteCommand(cmd string, args []string) (string, error)

	Console(stream StorageConsoleStream) error

	LocalConsole(writer io.StringWriter, errWriter io.StringWriter) error
}

type SystemEnvironmentPropertyResolver

type SystemEnvironmentPropertyResolver interface {
	PromptProperty(key string) (string, bool)

	Environ(withValues bool) []string
}

type Whois

type Whois struct {
	Domain    string
	NServer   []string
	State     string
	Person    string
	Email     string
	Registrar string
	Created   string
	PaidTill  string
}

type WhoisService

type WhoisService interface {
	Parse(whoisResp string) *Whois

	Whois(domain string) (string, error)
}

Jump to

Keyboard shortcuts

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