bolt

package
v0.0.0-...-a9e947c Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2023 License: MIT, Zlib Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DBVersionKey = "DB_VERSION"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type EndpointService

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

EndpointService represents a service for managing users.

func (*EndpointService) CreateEndpoint

func (service *EndpointService) CreateEndpoint(endpoint *whale.Endpoint) error

CreateEndpoint assign an ID to a new endpoint and saves it.

func (*EndpointService) DeleteEndpoint

func (service *EndpointService) DeleteEndpoint(ID whale.EndpointID) error

DeleteEndpoint deletes an endpoint.

func (*EndpointService) Endpoint

func (service *EndpointService) Endpoint(ID whale.EndpointID) (*whale.Endpoint, error)

Endpoint returns an endpoint by ID.

func (*EndpointService) Endpoints

func (service *EndpointService) Endpoints() ([]whale.Endpoint, error)

Endpoints return an array containing all the endpoints.

func (*EndpointService) Synchronize

func (service *EndpointService) Synchronize(toCreate, toUpdate, toDelete []*whale.Endpoint) error

Synchronize creates, updates and deletes endpoints inside a single transaction.

func (*EndpointService) UpdateEndpoint

func (service *EndpointService) UpdateEndpoint(ID whale.EndpointID, endpoint *whale.Endpoint) error

UpdateEndpoint updates an endpoint.

type Migrator

type Migrator struct {
	UserService            *UserService
	EndpointService        *EndpointService
	ResourceControlService *ResourceControlService
	VersionService         *VersionService
	CurrentDBVersion       int
	// contains filtered or unexported fields
}

func NewMigrator

func NewMigrator(store *Store, version int) *Migrator

func (*Migrator) Migrate

func (m *Migrator) Migrate() error

type ResourceControlService

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

ResourceControlService represents a service for managing resource controls.

func (*ResourceControlService) CreateResourceControl

func (service *ResourceControlService) CreateResourceControl(resourceID string, rc *whale.ResourceControl, rcType whale.ResourceControlType) error

CreateResourceControl creates a new resource control

func (*ResourceControlService) DeleteResourceControl

func (service *ResourceControlService) DeleteResourceControl(resourceID string, rcType whale.ResourceControlType) error

DeleteResourceControl deletes a resource control object by resource ID

func (*ResourceControlService) ResourceControl

func (service *ResourceControlService) ResourceControl(resourceID string, rcType whale.ResourceControlType) (*whale.ResourceControl, error)

ResourceControl returns a resource control object by resource ID

func (*ResourceControlService) ResourceControls

func (service *ResourceControlService) ResourceControls(rcType whale.ResourceControlType) ([]whale.ResourceControl, error)

ResourceControls returns all resource control objects

type Store

type Store struct {
	// Path where is stored the BoltDB database.
	Path string

	// Services
	UserService            *UserService
	EndpointService        *EndpointService
	ResourceControlService *ResourceControlService
	VersionService         *VersionService
	// contains filtered or unexported fields
}

Store defines the implementation of whale.DataStore using BoltDB as the storage system.

func NewStore

func NewStore(storePath string) (*Store, error)

NewStore initializes a new Store and the associated services

func (*Store) Close

func (store *Store) Close() error

Close closes the BoltDB database.

func (*Store) MigrateData

func (store *Store) MigrateData() error

MigrateData automatically migrate the data based on the DBVersion.

func (*Store) Open

func (store *Store) Open() error

Open opens and initializes the BoltDB database.

type UserService

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

UserService represents a service for managing users.

func (*UserService) CreateUser

func (service *UserService) CreateUser(user *whale.User) error

CreateUser creates a new user.

func (*UserService) DeleteUser

func (service *UserService) DeleteUser(ID whale.UserID) error

DeleteUser deletes a user.

func (*UserService) UpdateUser

func (service *UserService) UpdateUser(ID whale.UserID, user *whale.User) error

UpdateUser saves a user.

func (*UserService) User

func (service *UserService) User(ID whale.UserID) (*whale.User, error)

User returns a user by ID

func (*UserService) UserByUsername

func (service *UserService) UserByUsername(username string) (*whale.User, error)

UserByUsername returns a user by username.

func (*UserService) Users

func (service *UserService) Users() ([]whale.User, error)

Users return an array containing all the users.

func (*UserService) UsersByRole

func (service *UserService) UsersByRole(role whale.UserRole) ([]whale.User, error)

UsersByRole return an array containing all the users with the specified role.

type VersionService

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

EndpointService represents a service for managing users.

func (*VersionService) DBVersion

func (service *VersionService) DBVersion() (int, error)

DBVersion the stored database version.

func (*VersionService) StoreDBVersion

func (service *VersionService) StoreDBVersion(version int) error

StoreDBVersion store the database version.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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