domain

package
v0.0.0-...-646d846 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2022 License: Unlicense Imports: 6 Imported by: 0

Documentation

Overview

Package domain contains the domain models of our application. It does not contain any persistence logic; instead, that belongs in the repo package.

Our services are generally microservices, and therefore have a small enough scope for all of our models to live in one package. If you're building something with a larger scope (i.e. more monolith than microservice), it may make sense to break this into subpackages. However, make this decision very thoughtfully, and ensuring that your subpackages truly are independent, or else you may find yourself running into circular dependencies (an indication your packages were more coupled than you thought, and potentially shouldn't have been split up).

Expect this package to have few unit tests. For the most part, these are just models, without much logic. When do you do have logic in here (e.g. custom JSON marshaling, sort functions), consider writing unit tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	// ID is the database id for the account.
	ID int64

	// Created is when the account was created.
	Created time.Time

	// PasswordDigest is the SHA512 digest of the salt combined with the
	// plain-text password.
	PasswordDigest string

	// PasswordSalt is random bytes for securing the password digest.
	PasswordSalt string

	// Username is the account username.
	Username string
}

Account is a user account.

func (*Account) Authenticate

func (a *Account) Authenticate(password string) (bool, error)

Authenticate compares an incoming plain-text password with the expected password digest. It is safe to use with a nil account.

func (*Account) SetPassword

func (a *Account) SetPassword(password string) error

SetPassword creates and sets a new password digest and salt.

type Task

type Task struct {
	// ID is the database id for the task.
	ID int64

	// AccountID is the database foreign key to the account.
	AccountID int64

	// Completed is the time when the task was marked completed.
	Completed *time.Time

	// Created is the time when the task was created.
	Created time.Time

	// Description is the task description.
	Description string
}

Task is a single todo item which belongs to an account.

Jump to

Keyboard shortcuts

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