domain

package
v0.0.0-...-fa7900d Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MeterAlreadyExistError = errors.New("meter already exist")
View Source
var Module = fx.Module("domain", fx.Provide(func(e *env.Env,
	meterRepo kv.Repo[*entities.Meter],
	readingsRepo kv.Repo[*entities.Reading],
	logger logging.Logger,
	jc *nats.JetstreamClient,
	env *env.Env,
	meterProducer MeterProducer,
) (Domain, error) {
	return &Impl{
		meterRepo:     meterRepo,
		readingsRepo:  readingsRepo,
		logger:        logger,
		meterMap:      MeterMap{},
		oldMeterMap:   MeterMap{},
		jc:            jc,
		env:           env,
		meterProducer: meterProducer,
	}, nil
}))

Functions

func EventKey

func EventKey(id string) string

func MeterKey

func MeterKey(id string) string

Types

type Domain

type Domain interface {
	RegisterMeter(ctx context.Context, meter entities.Meter) error
	ListMeters(ctx context.Context) ([]kv.Entry[*entities.Meter], error)
	DeleteMeter(ctx context.Context, key string) error
	GetMeter(ctx context.Context, key string) (*entities.Meter, error)
	GetReading(ctx context.Context, key string) (*entities.Reading, error)

	ListReadings(ctx context.Context, pattern string) ([]kv.Entry[*entities.Reading], error)

	StartConsumingEvents(ctx context.Context) error

	AddMeterToConsume(meter *entities.Meter)
	RemoveMeterFromConsume(key string)
}

type Impl

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

func (*Impl) AddMeterToConsume

func (d *Impl) AddMeterToConsume(meter *entities.Meter)

func (*Impl) DeleteMeter

func (d *Impl) DeleteMeter(ctx context.Context, id string) error

func (*Impl) GetMeter

func (d *Impl) GetMeter(ctx context.Context, id string) (*entities.Meter, error)

func (*Impl) GetReading

func (d *Impl) GetReading(ctx context.Context, key string) (*entities.Reading, error)

func (*Impl) ListMeters

func (d *Impl) ListMeters(ctx context.Context) ([]kv.Entry[*entities.Meter], error)

func (*Impl) ListReadings

func (d *Impl) ListReadings(ctx context.Context, pattern string) ([]kv.Entry[*entities.Reading], error)

func (*Impl) RegisterMeter

func (d *Impl) RegisterMeter(ctx context.Context, meter entities.Meter) error

func (*Impl) RemoveMeterFromConsume

func (d *Impl) RemoveMeterFromConsume(key string)

func (*Impl) StartConsumingEvents

func (d *Impl) StartConsumingEvents(ctx context.Context) error

type MeterMap

type MeterMap map[string]*entities.Meter

func (MeterMap) Add

func (d MeterMap) Add(meter *entities.Meter)

func (MeterMap) AddMeters

func (d MeterMap) AddMeters(meters []*entities.Meter)

func (MeterMap) RemoveMeter

func (d MeterMap) RemoveMeter(key string)

type MeterProducer

type MeterProducer messaging.Producer

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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