platform

package module
v2.0.2 Latest Latest
Warning

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

Go to latest
Published: May 2, 2021 License: MIT Imports: 9 Imported by: 1

README

Simple (Cloud) Platform Abstractions

Cloud Platform abstractions and other shared code to build cloud-native services.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Logger

func Logger(logID string) logging.LoggingProvider

Logger returns a logger instance identified by ID

func Meter

func Meter(ctx context.Context, metric string, args ...string)

Meter logs args to a metrics log from where the values can be aggregated and analyzed.

func NewHttpContext

func NewHttpContext(req *h.Request) context.Context

NewHttpContext creates a new Http context for request req

func NewTask

func NewTask(task tasks.HttpTask) error

NewTask schedules a new http background task

func ReportError

func ReportError(e error)

ReportError reports error e using the current platform's error reporting provider

Types

type InstanceProviderFunc

type InstanceProviderFunc func(string) interface{}

type Platform

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

func DefaultPlatform

func DefaultPlatform() *Platform

DefaultPlatform returns the current default platform provider.

func InitPlatform

func InitPlatform(ctx context.Context, opts ...PlatformOpts) (*Platform, error)

InitPlatform creates a new platform instance and configures it with providers

func RegisterPlatform

func RegisterPlatform(p *Platform) *Platform

RegisterPlatform makes p the new default platform provider

func (*Platform) RegisterProvider

func (p *Platform) RegisterProvider(opt PlatformOpts, ignoreExists bool) error

RegisterProvider registers a provider. An existing provider will be overwritten if ignoreExists is true, otherwise the function returns an error

type PlatformOpts

type PlatformOpts struct {
	ID   string
	Type ProviderType
	Impl InstanceProviderFunc
}

func WithProvider

func WithProvider(ID string, providerType ProviderType, impl InstanceProviderFunc) PlatformOpts

WithProvider returns a populated PlatformOption struct.

type ProviderType

type ProviderType int
const (
	ProviderTypeLogger ProviderType = iota
	ProviderTypeErrorReporter
	ProviderTypeHttpContext
	ProviderTypeTask
	ProviderTypeMetrics
)

func (ProviderType) String

func (l ProviderType) String() string

Returns the name of a provider type

Directories

Path Synopsis
pkg
api
env
id
provider

Jump to

Keyboard shortcuts

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