Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConnectionOptions ¶
type ConnectionOptions struct {
Address string
}
type Db ¶
type Db interface { // Connect actually connects to the database Connect(ctx context.Context) error // Ping pings the database to check connectivity Ping(ctx context.Context) error // CreateUser creates a user in the database CreateUser(ctx context.Context, entry UserEntry) error // GetIDByEmail returns the user's ID or empty string if not found. // Returns an error if something unexpected goes wrong. GetIDByEmail(ctx context.Context, email string) (string, error) // GetUserByID returns the user's entry or nil if not found. // Returns an error if something unexpected goes wrong. GetUserByID(ctx context.Context, id string) (*UserEntry, error) // it will atomically store the given value and return that. GetSharedValue(ctx context.Context, key string, ifNotExist string) (string, error) // WaitForCreateUser will wait for the user to be created // in the database before returning, or an error if the user // was not seen as added before the context cancels WaitForCreateUser(ctx context.Context, id string) error }
Db is a persistent database that stores user information
func New ¶
func New(opts ConnectionOptions) Db
type UserEntry ¶
type UserEntry struct { // ID is some uniquely generated identifier attached to the user ID string // Email is the user's email address Email string // PasswordHash is the hashed/salted password that will be used // for comparison/validation PasswordHashWithSalt string }
UserEntry is a single row in the database
Click to show internal directories.
Click to hide internal directories.