core

package
v0.7.8 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2022 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	Code string
	Name string
}

func NewAccount

func NewAccount(code, name string) (*Account, error)

type Currency

type Currency struct {
	Name     string
	Decimals int
}

func NewCurrency

func NewCurrency(name string, decimals int) (*Currency, error)

type Service

type Service interface {
	// Start spawns any goroutines required by the service.
	Start()
	// Stop terminates all goroutines belonging to the service,
	// blocking until they are all terminated.
	Stop() error
	// Returns error if the service is not considered healthy.
	Status() error
}

Service is a struct that can be registered into a ServiceRegistry for easy dependency management.

type ServiceRegistry

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

ServiceRegistry provides a useful pattern for managing services. It allows for ease of dependency management and ensures services dependent on others use the same references in memory.

func NewServiceRegistry

func NewServiceRegistry() *ServiceRegistry

NewServiceRegistry starts a registry instance for convenience

func (*ServiceRegistry) FetchService

func (s *ServiceRegistry) FetchService(service interface{}) error

FetchService takes in a struct pointer and sets the value of that pointer to a service currently stored in the service registry. This ensures the input argument is set to the right pointer that refers to the originally registered service.

func (*ServiceRegistry) RegisterService

func (s *ServiceRegistry) RegisterService(service Service) error

RegisterService appends a service constructor function to the service registry.

func (*ServiceRegistry) StartAll

func (s *ServiceRegistry) StartAll()

StartAll initialized each service in order of registration.

func (*ServiceRegistry) Statuses

func (s *ServiceRegistry) Statuses() map[reflect.Type]error

Statuses returns a map of Service type -> error. The map will be populated with the results of each service.Status() method call.

func (*ServiceRegistry) StopAll

func (s *ServiceRegistry) StopAll()

StopAll ends every service in reverse order of registration, logging a panic if any of them fail to stop.

type Split

type Split struct {
	Id          string
	Date        time.Time
	Description []byte
	Accounts    []*Account
	Currency    *Currency
	Amount      *big.Int
}

func NewSplit

func NewSplit(date time.Time, desc []byte, accs []*Account, cur *Currency, amt *big.Int) (*Split, error)

type TBAccount

type TBAccount struct {
	Account  string   `json:"Account"`
	Amount   int      `json:"Amount"`
	Tags     []string `json:"Tags"`
	Currency string   `json:"Currency"`
	Decimals int      `json:"Decimals"`
}

type Transaction

type Transaction struct {
	Id          string
	Postdate    time.Time
	Poster      *User
	Description []byte
	Splits      []*Split
}

func NewTransaction

func NewTransaction(usr *User) (*Transaction, error)

func ReverseTransaction added in v0.3.0

func ReverseTransaction(originalTxn *Transaction, usr *User) (*Transaction, error)

func (*Transaction) AppendSplit

func (txn *Transaction) AppendSplit(spl *Split) error

func (*Transaction) Balance

func (txn *Transaction) Balance() (*big.Int, bool)

type User

type User struct {
	Id   string
	Name string
}

func NewUser

func NewUser(name string) (*User, error)

Jump to

Keyboard shortcuts

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