service

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAccountAlreadyExists = errors.New("account already exists")
	ErrAccountNotFound      = errors.New("account not found")
	ErrShareCodeInvalid     = errors.New("share code is invalid")
)
View Source
var (
	ErrWritingModuleFailed = errors.New("module write failed")
	ErrReadingModule       = errors.New("module read failed")
)
View Source
var ErrDeviceNotFound = errors.New("device not found")
View Source
var ErrNoMetadata = errors.New("no metadata found")

Functions

This section is empty.

Types

type Account

type Account interface {
	Username() string
	CreatedAt() time.Time
}

type Accounts

type Accounts interface {
	Find(ctx context.Context, username string) (Account, error)
	Create(ctx context.Context, username string) (Account, error)

	HealthCheck() HealthCheck
}

type BaseAccount

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

func NewBaseAccount

func NewBaseAccount(username string, createdAt time.Time) *BaseAccount

func (*BaseAccount) CreatedAt

func (r *BaseAccount) CreatedAt() time.Time

func (*BaseAccount) Username

func (r *BaseAccount) Username() string

type BaseDevice

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

func NewBaseDevice

func NewBaseDevice(deviceId DeviceID, hashedPass string) *BaseDevice

func (*BaseDevice) HashedPass

func (r *BaseDevice) HashedPass() string

func (*BaseDevice) ID

func (r *BaseDevice) ID() DeviceID

func (*BaseDevice) Verify

func (r *BaseDevice) Verify(password string) bool

type BaseMetadata

type BaseMetadata struct {
	ID         MetadataID `json:"id"         yaml:"id"`
	ModifiedAt time.Time  `json:"modifiedAt" yaml:"modifiedAt"`
}

func NewBaseMetadata

func NewBaseMetadata(id string, modifiedAt time.Time) *BaseMetadata

func (*BaseMetadata) GetID

func (r *BaseMetadata) GetID() MetadataID

func (*BaseMetadata) GetModifiedAt

func (r *BaseMetadata) GetModifiedAt() ModifiedAt

type Device

type Device interface {
	ID() DeviceID
	Verify(password string) bool
	HashedPass() string
}

type DeviceID

type DeviceID uuid.UUID

func (DeviceID) String

func (i DeviceID) String() string

func (DeviceID) UUID

func (i DeviceID) UUID() uuid.UUID

type Devices

type Devices interface {
	AddDevice(ctx context.Context, account Account, id DeviceID, password string) (Device, error)
	GetDevices(ctx context.Context, account Account) (map[DeviceID]Device, error)
	GetDevice(ctx context.Context, account Account, id DeviceID) (Device, error)
	DeleteDevice(ctx context.Context, account Account, id DeviceID) error

	HealthCheck() HealthCheck
}

type Health

type Health interface {
	Check(ctx context.Context) HealthAggregation
}

func HealthAggregator

func HealthAggregator(healthChecks []HealthCheck) Health

type HealthAggregation

type HealthAggregation struct {
	Health     HealthResult                 `yaml:"health"`
	Components []HealthAggregationComponent `yaml:"components"`
}

type HealthAggregationComponent

type HealthAggregationComponent struct {
	Name   string       `yaml:"name"`
	Health HealthResult `yaml:"health"`
}

type HealthCheck

type HealthCheck func(ctx context.Context) (string, bool)

type HealthResult

type HealthResult string
const (
	HealthUp   HealthResult = "Up"
	HealthDown HealthResult = "Down"
)

func HealthResultFromBool

func HealthResultFromBool(healthUp bool) HealthResult

func (HealthResult) ToHTTPStatusCode

func (r HealthResult) ToHTTPStatusCode() int

type Metadata

type Metadata interface {
	GetID() MetadataID
	GetModifiedAt() ModifiedAt
}

type MetadataID

type MetadataID string

type MetadataProvider

type MetadataProvider interface {
	Get(ctx context.Context, id MetadataID) (Metadata, error)
	Set(ctx context.Context, meta Metadata) error
}

type ModifiedAt

type ModifiedAt time.Time

type Module

type Module interface {
	Raw() io.Reader
	Size() int
}

type Modules

type Modules interface {
	Set(ctx context.Context, name string, module Module) error
	Get(ctx context.Context, name string) (Module, error)
	HealthCheck() HealthCheck
	DeleteByPattern(ctx context.Context, pattern string) error
}

type ShareCode

type ShareCode string

func (ShareCode) String

func (c ShareCode) String() string

type Sharing

type Sharing interface {
	Share(ctx context.Context, account Account) (ShareCode, error)
	Shared(ctx context.Context, shareCode ShareCode) (Account, error)
	Revoke(ctx context.Context, shareCode ShareCode) error
}

type UsernameGenerationStrategy

type UsernameGenerationStrategy string
const UUIDUsernameGeneration UsernameGenerationStrategy = "uuid"

type UsernameGenerator

type UsernameGenerator interface {
	Generate() (string, error)
}

Directories

Path Synopsis
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.
mock
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.

Jump to

Keyboard shortcuts

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