sparks

package module
v1.6.5 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2020 License: Apache-2.0 Imports: 10 Imported by: 1

README

sparks

Model Rocket Cloud Core Library

Documentation

Overview

Package sparks provides the interfaces and manager for cloud providers

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUserPoolNotFound is returned when a user pool does not exist
	ErrUserPoolNotFound = errors.New("user pool not found")

	// ErrUserNotFound is returned when a user does not exist
	ErrUserNotFound = errors.New("user not found")

	// ErrUserExists is returned when a user exists and there is a conflict
	ErrUserExists = errors.New("user with that username exists")

	// ErrUserDisabled is returned when a user is disabled
	ErrUserDisabled = errors.New("user disabled")

	// ErrPasswordExpired is returned when a user's password is expired
	ErrPasswordExpired = errors.New("password expired")

	// ErrObjectStoreNotFound is returned when an object store does not exist
	ErrObjectStoreNotFound = errors.New("store not found")

	// ErrObjectNotFound is returned when a object does not exist
	ErrObjectNotFound = errors.New("object not found")

	// ErrNotImplemented is returns when an interface method is not implemented or supported
	ErrNotImplemented = errors.New("not implemented")
)
View Source
var (
	// QueueErrorScanCancel can be returned by the scan handler to stop scanning
	QueueErrorScanCancel = QueueError(errors.New("scan canceled"))
)

Functions

func Getenv

func Getenv(key string, prov ...Provider) string

Getenv decrypt a base64 encoded encrypted env var using the Encryption provider

func GetenvParams

func GetenvParams(key string, prov ...Provider) types.Params

GetenvParams returns a parameters structure from the env var

func LookupEnv

func LookupEnv(key string, prov ...Provider) ([]byte, error)

LookupEnv decrypt a base64 encoded encrypted env var using the Encryption provider

func RegisterProvider

func RegisterProvider(name string, provider NewFunc)

RegisterProvider makes a database provider available by the provided name. If RegisterProvider is called twice with the same name or if provider is nil, it panics.

Types

type Attributes

type Attributes = types.Params

Attributes is an alias for reno/types.Params

type EncryptionProvider

type EncryptionProvider interface {
	// Decrypt descrypts the bytes
	Decrypt([]byte, Params) ([]byte, error)

	// Encrypt encrypts the bytes
	Encrypt([]byte, Params) ([]byte, error)
}

EncryptionProvider is an interface that provides generic encryption mechanisms

type NewFunc

type NewFunc func(params Params) (Provider, error)

NewFunc is a function registered with the cloud layer for creating a new instance of the provider.

type ObjectProvider

type ObjectProvider interface {
	// OpenObjectStore store returns an object store with the given name and parameter
	OpenObjectStore(name string, params ...Params) (ObjectStore, error)
}

ObjectProvider provides an object store

type ObjectStore

type ObjectStore interface {
	// GetObject returns an io.Reader that allows for getting the object data
	GetObject(key string, params ...Params) (io.Reader, error)

	// GetObjectLink returns a secure http link to the object
	GetObjectLink(key string, timeout time.Duration, write ...bool) (*types.Link, error)

	// PutObject set the value
	PutObject(key string, r io.Reader, params ...Params) error

	// DeleteObject deletes and object
	DeleteObject(key string, params ...Params) error

	// StatObject returns properties of the object
	StatObject(key string) (types.StringMap, error)

	// ListObjects returns a list of object keys for the specified prefix
	ListObjects(prefix string) ([]os.FileInfo, error)

	// Name returns the object store name
	Name() string
}

ObjectStore is an interface for kv object stores implemented by providers

func DefaultObjectStore

func DefaultObjectStore() ObjectStore

DefaultObjectStore returns the default object store based on the env or panics

type Params

type Params = types.Params

Params is an alias for reno/types.Params

type Provider

type Provider interface {
	// Name returns the provider name
	Name() string

	// Close is called to cleanup the provider
	Close()
}

Provider is a base interface that must be implemented by cloud providers

func DefaultProvider

func DefaultProvider() Provider

DefaultProvider returns the default based on the environment provider or panics

func OpenProvider

func OpenProvider(name string, params types.Params) (Provider, error)

OpenProvider opens a new cloud provider instance with the specified parameters

type Queue

type Queue interface {
	// Publish publishes the message body with optioanl attributes and return the id
	Publish(body []byte, attributes ...Attributes) (string, error)

	// Scan performs a canceleable scan on the queue
	Scan(ctx context.Context, handler func(msg QueueMessage) error) error
}

Queue defines a queue interface

type QueueError

type QueueError error

QueueError is a queue error type

type QueueMessage

type QueueMessage interface {
	// MessageID returns a unique message identifier
	MessageID() string

	// Body returns the message body as []byte
	Body() []byte

	// Attributes returns the message attributes as a map
	Attributes() types.StringMap
}

QueueMessage is a queue message interface

type QueueProvider

type QueueProvider interface {
	OpenQueue(name string, params Params) (Queue, error)
}

QueueProvider defines a queue provider interface

type User

type User interface {
	// Login returns the user login i.e. username
	Login() string

	// Attributes returns a map of user attributes
	Attributes() types.StringMap

	// Status returns the user status as a string
	Status() string

	// Enabled represents the user's status
	Enabled() bool

	// Groups returns a list of groups the user belongs to
	Groups() []string
}

User is a common user interface

type UserPool

type UserPool interface {
	// AuthenticateUser authenticates the user and returns an AuthToken
	AuthenticateUser(username, password string) (keychain.AuthToken, error)

	// CreateUser creates a new user
	CreateUser(username, password string, attributes map[string]string, options ...Params) (User, error)

	// ChangeUserPassword attempts to change the users password from current to the proposed
	ChangeUserPassword(username, current, proposed string) error

	// GetUser returns a user
	GetUser(username string) (User, error)

	// UpdateUser updates a users attributes
	UpdateUser(username string, attributes types.StringMap) error

	// DeleteUser deletes a user record
	DeleteUser(username string) error

	// DisableUser disables a user account
	DisableUser(username string) error
}

UserPool is an interface implemented by providers that support users

type UserProvider

type UserProvider interface {
	// OpenUserPool returns a user pool with the given name and parameters
	OpenUserPool(name string, options Params) (UserPool, error)
}

UserProvider is an interface for getting a UserPool from the provider

Directories

Path Synopsis
Package keychain manages the validation and processing of jwt/oauth tokens
Package keychain manages the validation and processing of jwt/oauth tokens
providers
aws

Jump to

Keyboard shortcuts

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