galaxybus

package
v0.0.0-...-da924b9 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OrderByID      = "galaxy_id"
	OrderByName    = "name"
	OrderByEnabled = "enabled"
)

Set of fields that the results can be ordered by.

Variables

View Source
var (
	ErrNotFound              = errors.New("galaxy not found")
	ErrUniqueEmail           = errors.New("email is not unique")
	ErrAuthenticationFailure = errors.New("authentication failed")
)

Set of error variables for CRUD operations.

View Source
var DefaultOrderBy = order.NewBy(OrderByID, order.ASC)

DefaultOrderBy represents the default way we sort.

View Source
var Names nameSet

Functions

This section is empty.

Types

type Business

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

Business manages the set of APIs for galaxy access.

func NewBusiness

func NewBusiness(log *logger.Logger, storer Storer) *Business

NewBusiness constructs a galaxy business API for use.

func (*Business) Count

func (b *Business) Count(ctx context.Context, filter QueryFilter) (int, error)

Count returns the total number of galaxies.

func (*Business) Create

func (b *Business) Create(ctx context.Context, nu NewGalaxy) (Galaxy, error)

Create adds a new galaxy to the system.

func (*Business) Delete

func (b *Business) Delete(ctx context.Context, gal Galaxy) error

Delete removes the specified galaxy.

func (*Business) Query

func (b *Business) Query(ctx context.Context, filter QueryFilter, orderBy order.By, pageNumber int, rowsPerPage int) ([]Galaxy, error)

Query retrieves a list of existing galaxies.

func (*Business) QueryByID

func (b *Business) QueryByID(ctx context.Context, galaxyID uuid.UUID) (Galaxy, error)

QueryByID finds the galaxy by the specified Ib.

func (*Business) QueryByName

func (b *Business) QueryByName(ctx context.Context, galaxyName string) (Galaxy, error)

QueryByName finds the galaxy by the specified Ib.

func (*Business) Update

func (b *Business) Update(ctx context.Context, gal Galaxy, uu UpdateGalaxy) (Galaxy, error)

Update modifies information about a galaxy.

type Galaxy

type Galaxy struct {
	ID          uuid.UUID
	Name        Name
	OwnerUserID uuid.UUID
	Enabled     bool
	DateCreated time.Time
	DateUpdated time.Time
}

Galaxy represents information about an individual galaxy.

func TestSeedGalaxies

func TestSeedGalaxies(ctx context.Context, n int, api *Business) ([]Galaxy, error)

TestSeedGalaxies is a helper method for testing.

type Name

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

Name represents a name in the system.

func (Name) Equal

func (n Name) Equal(n2 Name) bool

Equal provides support for the go-cmp package and testing.

func (Name) MarshalText

func (n Name) MarshalText() ([]byte, error)

MarshalText implement the marshal interface for JSON conversions.

func (Name) String

func (n Name) String() string

String returns the value of the name.

func (*Name) UnmarshalText

func (n *Name) UnmarshalText(data []byte) error

UnmarshalText implement the unmarshal interface for JSON conversions.

type NewGalaxy

type NewGalaxy struct {
	Name        Name
	OwnerUserID uuid.UUID
}

NewGalaxy contains information needed to create a new galaxy.

func TestNewGalaxies

func TestNewGalaxies(n int) []NewGalaxy

TestNewGalaxies is a helper method for testing.

type QueryFilter

type QueryFilter struct {
	ID          *uuid.UUID
	Name        *Name
	CreatedDate *time.Time
}

QueryFilter holds the available fields a query can be filtered on. We are using pointer semantics because the With API mutates the value.

type Storer

type Storer interface {
	Create(ctx context.Context, gal Galaxy) error
	Update(ctx context.Context, gal Galaxy) error
	Delete(ctx context.Context, gal Galaxy) error
	Query(ctx context.Context, filter QueryFilter, orderBy order.By, pageNumber int, rowsPerPage int) ([]Galaxy, error)
	Count(ctx context.Context, filter QueryFilter) (int, error)
	QueryByID(ctx context.Context, galaxyID uuid.UUID) (Galaxy, error)
	QueryByName(ctx context.Context, galaxyName string) (Galaxy, error)
}

Storer interface declares the behavior this package needs to perists and retrieve data.

type UpdateGalaxy

type UpdateGalaxy struct {
	Name        *Name
	OwnerUserID *uuid.UUID
	Enabled     *bool
}

UpdateGalaxy contains information needed to update a galaxy.

Directories

Path Synopsis
stores

Jump to

Keyboard shortcuts

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