fresh

package module
v0.0.0-...-c40f766 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2023 License: MIT Imports: 12 Imported by: 0

README

go-sdk

Fresh Golang SDK

Documentation

Index

Constants

View Source
const (
	PluginNameApplication       string = "fresh-application"
	MagicCookieKeyApplication   string = "FRESH_APPLICATION_PLUGIN"
	MagicCookieValueApplication string = "4ab23e44-f2c4-44c2-9b66-448d78d4713c"
)
View Source
const (
	PluginNameCron       string = "fresh-cron"
	MagicCookieKeyCron   string = "FRESH_CRON_PLUGIN"
	MagicCookieValueCron string = ""
)

Variables

This section is empty.

Functions

func NewFresherApplication

func NewFresherApplication(f FreshApplication) error

func NewFresherCron

func NewFresherCron(f FreshCron) error

func NewImage

func NewImage()

func NewImageRegistry

func NewImageRegistry()

Types

type Application

type Application struct {
	Name          string
	Image         *Image
	ImageRegistry *ImageRegistry
	Resources     *Resources
}

func NewApplication

func NewApplication(opts ...ApplicationOption) (*Application, error)

func (*Application) String

func (a *Application) String() string

type ApplicationOption

type ApplicationOption func(*Application)

func WithApplicationImage

func WithApplicationImage(image *Image) ApplicationOption

func WithApplicationImageRegistry

func WithApplicationImageRegistry(registry *ImageRegistry) ApplicationOption

func WithApplicationName

func WithApplicationName(name string) ApplicationOption

func WithApplicationResource

func WithApplicationResource(res *Resources) ApplicationOption

type Cron

type Cron struct {
	Name          string
	Image         *Image
	ImageRegistry *ImageRegistry
	Resources     *Resources
	SecretHandler *SecretHandler
	Dictionary    *Dictionary
	Queue         *Queue
	Volume        *Volume
}

func NewCron

func NewCron(opts ...CronOption) (*Cron, error)

func (*Cron) String

func (c *Cron) String() string

type CronOption

type CronOption func(*Cron)

func WithCronImage

func WithCronImage(image *Image) CronOption

func WithCronImageRegistry

func WithCronImageRegistry(registry *ImageRegistry) CronOption

func WithCronName

func WithCronName(name string) CronOption

func WithCronResource

func WithCronResource(res *Resources) CronOption

type Dictionary

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

func NewDictionary

func NewDictionary() (*Dictionary, error)

func (*Dictionary) Delete

func (d *Dictionary) Delete(key string) error

func (*Dictionary) Exists

func (d *Dictionary) Exists(key string) (bool, error)

func (*Dictionary) Get

func (d *Dictionary) Get(key string) ([]byte, error)

func (*Dictionary) Length

func (d *Dictionary) Length(key string) (int32, error)

func (*Dictionary) Pop

func (d *Dictionary) Pop(key string) ([]byte, error)

func (*Dictionary) Put

func (d *Dictionary) Put(key string, value []byte) error

Put add the value to the list of other objects for the given key example: "key": ["val1","val2","val3"]

type FreshApplication

type FreshApplication interface {
	// EntryPoint defines the "main" function
	EntryPoint() error
	// Shutdown defines the place to tear down things where necessary
	Shutdown() error
	// GetApplication returns the actual application containing all the information
	GetApplication() (*Application, error)
}

type FreshApplicationPlugin

type FreshApplicationPlugin struct {
	Impl FreshApplication
}

func (FreshApplicationPlugin) Client

func (FreshApplicationPlugin) Client(b *plugin.MuxBroker, c *rpc.Client) (interface{}, error)

func (*FreshApplicationPlugin) Server

func (p *FreshApplicationPlugin) Server(*plugin.MuxBroker) (interface{}, error)

type FreshApplicationRPC

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

func (*FreshApplicationRPC) EntryPoint

func (f *FreshApplicationRPC) EntryPoint() error

func (*FreshApplicationRPC) GetApplication

func (f *FreshApplicationRPC) GetApplication() (*Application, error)

func (*FreshApplicationRPC) Shutdown

func (f *FreshApplicationRPC) Shutdown() error

type FreshApplicationRPCServer

type FreshApplicationRPCServer struct {
	Impl FreshApplication
}

func (*FreshApplicationRPCServer) EntryPoint

func (s *FreshApplicationRPCServer) EntryPoint(args interface{}, resp *error) error

func (*FreshApplicationRPCServer) GetApplication

func (s *FreshApplicationRPCServer) GetApplication(args interface{}, resp *Application) error

func (*FreshApplicationRPCServer) Shutdown

func (s *FreshApplicationRPCServer) Shutdown(args interface{}, resp *error) error

type FreshCron

type FreshCron interface {
	GetCron() (*Cron, error)
	Execute(args *pb.CronExecuteRequest) *pb.CronExecuteResponse
}

type FreshCronPlugin

type FreshCronPlugin struct {
	Impl FreshCron
}

func (FreshCronPlugin) Client

func (FreshCronPlugin) Client(b *plugin.MuxBroker, c *rpc.Client) (interface{}, error)

func (*FreshCronPlugin) Server

func (p *FreshCronPlugin) Server(*plugin.MuxBroker) (interface{}, error)

type FreshCronRPC

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

func (*FreshCronRPC) Execute

func (*FreshCronRPC) GetCron

func (f *FreshCronRPC) GetCron() *Cron

type FreshCronRPCServer

type FreshCronRPCServer struct {
	Impl FreshCron
}

func (*FreshCronRPCServer) Execute

func (s *FreshCronRPCServer) Execute(args interface{}, resp *pb.CronExecuteResponse) error

func (*FreshCronRPCServer) GetCron

func (s *FreshCronRPCServer) GetCron(args interface{}, resp *Cron) error

type FreshError

type FreshError struct {
	Code    string `json:"code"`
	Message string `json:"message"`
}

func (*FreshError) Error

func (err *FreshError) Error() string

type Image

type Image struct {
	Commands []string
}

func (*Image) CopyLocalDir

func (i *Image) CopyLocalDir() error

func (*Image) CopyLocalFile

func (i *Image) CopyLocalFile() error

func (*Image) CopyMount

func (i *Image) CopyMount() error

func (*Image) DockerfileCommands

func (i *Image) DockerfileCommands() error

func (*Image) RunCommands

func (i *Image) RunCommands() error

func (*Image) String

func (i *Image) String() string

type ImageRegistry

type ImageRegistry struct {
	URL        string
	Repository string
}

func (*ImageRegistry) Resolve

func (ir *ImageRegistry) Resolve() error

func (*ImageRegistry) String

func (ir *ImageRegistry) String() string

type Queue

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

func NewQueue

func NewQueue() (*Queue, error)

func (*Queue) Consume

func (q *Queue) Consume(topic string, messages chan<- []byte) error

func (*Queue) Produce

func (q *Queue) Produce(topic string, data []byte) (bool, error)

type ResourceOption

type ResourceOption func(*Resources)

func WithResourcesCPU

func WithResourcesCPU(value string) ResourceOption

func WithResourcesDisk

func WithResourcesDisk(value string) ResourceOption

func WithResourcesMemory

func WithResourcesMemory(value string) ResourceOption

type Resources

type Resources struct {
	CPU    int64
	Memory int64
	Disk   int64
}

func NewResource

func NewResource(opts ...ResourceOption) *Resources

func (*Resources) String

func (r *Resources) String() string

type SecretHandler

type SecretHandler struct {
	ApplicationID string
	// contains filtered or unexported fields
}

func NewSecretHandler

func NewSecretHandler(applicationID string, opts ...SecretHandlerOption) (*SecretHandler, error)

func (*SecretHandler) Add

func (s *SecretHandler) Add(key string, secret string) error

type SecretHandlerOption

type SecretHandlerOption func(*SecretHandler)

func WithSecretHandlerEnvFile

func WithSecretHandlerEnvFile(filename string) SecretHandlerOption

func WithSecretHandlerEnvMap

func WithSecretHandlerEnvMap(envMap map[string]string) SecretHandlerOption

type Volume

type Volume struct {
	Name string
	Path string
	// Size is expressed in MB with a default of 150
	Size int
}

func NewVolume

func NewVolume(name, path string, opts ...VolumeOption) (*Volume, error)

func (*Volume) String

func (v *Volume) String() string

func (*Volume) WalkDirectory

func (v *Volume) WalkDirectory() ([]string, error)

type VolumeOption

type VolumeOption func(*Volume)

func WithVolumeSize

func WithVolumeSize(size int) VolumeOption

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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