registry

package
v0.0.0-...-2d2b785 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2017 License: Apache-2.0 Imports: 12 Imported by: 0

README

DB

residents

column type description
id int internal id for a resident
firstname string first name of the resident
middlename string middle name of the resident
lastname string last name of the resident

units_residents

column type description
unit int unit id
resident int resident id

units

column type description
id int internal id for a unit
display_name string unit name, usually a number

buildings

column type description
id int internal id for a building
name string name of the building
address string address of the building

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Building

type Building struct {
	ID      string `dynamodbav:"building_id"`
	Name    string
	Address string
}

Building describes a building

type DynamoConfig

type DynamoConfig struct {
	BuildingTableName string
	UnitTableName     string
	ResidentTableName string
}

DynamoConfig holds config options for DynamoRegistrar

type DynamoRegistrar

type DynamoRegistrar struct {
	DB     dynamodbiface.DynamoDBAPI
	Config *DynamoConfig
}

DynamoRegistrar implements Registrar using dynamodb

func (*DynamoRegistrar) DeregisterBuilding

func (dr *DynamoRegistrar) DeregisterBuilding(ctx context.Context, buildingID string) (err error)

DeregisterBuilding implements Registrar

func (*DynamoRegistrar) DeregisterResident

func (dr *DynamoRegistrar) DeregisterResident(ctx context.Context, residentID string) (err error)

DeregisterResident implements Registrar

func (*DynamoRegistrar) DeregisterUnit

func (dr *DynamoRegistrar) DeregisterUnit(ctx context.Context, unitID string) (err error)

DeregisterUnit implements Registrar

func (*DynamoRegistrar) GetBuildingByID

func (dr *DynamoRegistrar) GetBuildingByID(ctx context.Context, buildingID string) (building *Building, err error)

GetBuildingByID implements registrar

func (*DynamoRegistrar) GetResidentByID

func (dr *DynamoRegistrar) GetResidentByID(ctx context.Context, residentID string) (resident *Resident, err error)

GetResidentByID implements registrar

func (*DynamoRegistrar) ListBuildingUnits

func (dr *DynamoRegistrar) ListBuildingUnits(ctx context.Context, buildingID string) (units []*Unit, err error)

ListBuildingUnits implements Registrar

func (*DynamoRegistrar) ListBuildings

func (dr *DynamoRegistrar) ListBuildings(ctx context.Context) (buildings []*Building, err error)

ListBuildings returns list of all buildings

func (*DynamoRegistrar) ListUnitResidents

func (dr *DynamoRegistrar) ListUnitResidents(ctx context.Context, unitID string) (residents []*Resident, err error)

ListUnitResidents implements Registrar

func (*DynamoRegistrar) MoveResidentIn

func (dr *DynamoRegistrar) MoveResidentIn(ctx context.Context, residentID, unitID string) (err error)

MoveResidentIn implements Registrar

func (*DynamoRegistrar) MoveResidentOut

func (dr *DynamoRegistrar) MoveResidentOut(ctx context.Context, residentID, unitID string) (err error)

MoveResidentOut implements Registrar

func (*DynamoRegistrar) RegisterBuilding

func (dr *DynamoRegistrar) RegisterBuilding(ctx context.Context, in *Building) (building *Building, err error)

RegisterBuilding implements Registrar

func (*DynamoRegistrar) RegisterResident

func (dr *DynamoRegistrar) RegisterResident(ctx context.Context, in *Resident) (out *Resident, err error)

RegisterResident implements Registrar

func (*DynamoRegistrar) RegisterUnit

func (dr *DynamoRegistrar) RegisterUnit(ctx context.Context, buildingID string, in *Unit) (unit *Unit, err error)

RegisterUnit implements Registrar

type Registrar

type Registrar interface {
	ListBuildings(ctx context.Context) (buildings []*Building, err error)

	GetBuildingByID(ctx context.Context, buildingID string) (building *Building, err error)

	RegisterBuilding(ctx context.Context, in *Building) (building *Building, err error)

	DeregisterBuilding(ctx context.Context, buildingID string) (err error)

	ListBuildingUnits(ctx context.Context, buildingID string) (units []*Unit, err error)

	// register unit
	RegisterUnit(ctx context.Context, buildingID string, in *Unit) (unit *Unit, err error)

	DeregisterUnit(ctx context.Context, unitID string) (err error)

	ListUnitResidents(ctx context.Context, unitID string) (residents []*Resident, err error)

	GetResidentByID(ctx context.Context, residentID string) (resident *Resident, err error)

	// adds a resident into the registry, optionally attaching the resident to
	// a unit if unitID is not empty.
	RegisterResident(ctx context.Context, resident *Resident) (returned *Resident, err error)

	DeregisterResident(ctx context.Context, residentID string) (err error)

	// moves a resident to a new unit
	MoveResidentIn(ctx context.Context, residentID, newUnitID string) (err error)

	// moves a resident out of a unitj
	MoveResidentOut(ctx context.Context, residentID, unitID string) (err error)
}

Registrar maintains a registry of units and residents

type Resident

type Resident struct {
	ID string `dynamodbav:"resident_id"`

	Firstname  string
	Middlename string
	Lastname   string
}

Resident represents a resident in liszt

func (*Resident) String

func (res *Resident) String() string

type Unit

type Unit struct {
	ID   string
	Name string
}

Unit describes a unit in liszt

Directories

Path Synopsis
Code generated by mockery v1.0.0
Code generated by mockery v1.0.0

Jump to

Keyboard shortcuts

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