unit

package
v0.0.0-...-7d41a23 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2019 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package unit contains all code related to the unit domain.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

type Backend interface {
	ListUnits() (List, error)
	GetUnit(id string) (Unit, error)
	CreateUnit(Unit) error
	UpdateUnit(Unit) error
	AppendUnit(Unit) error
	RemoveUnit(Unit) error
	DeleteUnit(id string) error
	UseUnit(id string)
}

Backend interface.

type Driver

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

Driver is the entry point of the domain that expose methods.

func NewDriver

func NewDriver(backend Backend) Driver

NewDriver create a new domain driver with given driven implementations.

func (Driver) Append

func (d Driver) Append(u Unit) error

Append attributes to the unit with id.

func (Driver) Apply

func (d Driver) Apply(u Unit) (updated bool, err error)

Apply new attributes to an existing unit, or create a new one.

func (Driver) Create

func (d Driver) Create(u Unit) error

Create a new unit.

func (Driver) Delete

func (d Driver) Delete(id string) error

Delete the unit with id.

func (Driver) Get

func (d Driver) Get(id string) (Unit, error)

Get the unit with id.

func (Driver) List

func (d Driver) List() (List, error)

List all units.

func (Driver) Remove

func (d Driver) Remove(u Unit) error

Remove attributes from the unit with id.

func (Driver) Update

func (d Driver) Update(u Unit) error

Update the unit with id.

func (Driver) Upsert

func (d Driver) Upsert(u Unit) (updated bool, err error)

Upsert the unit with id (update or create).

func (Driver) Use

func (d Driver) Use(id string)

Use ask the backend to start using this unit as default unit.

type List

type List interface {
	All() []Unit
	Index(idx uint) Unit
	Len() uint
	String() string
	MarshalJSON() ([]byte, error)
	MarshalYAML() (interface{}, error)
}

List of unit objects.

func NewList

func NewList(slice []Unit) List

NewList create a new list of units object.

type Unit

type Unit interface {
	ID() string
	Description() string
	String() string
	MarshalJSON() ([]byte, error)
	MarshalYAML() (interface{}, error)
}

Unit object contains information about an organizational unit.

func NewUnit

func NewUnit(id, decription string) Unit

NewUnit create a new unit object.

Jump to

Keyboard shortcuts

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