storage

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TrialStateOpen   = "open"
	TrialStateClosed = "closed"
)

State Constants

Variables

View Source
var ErrBadSetting = errors.New("bad setting")

ErrBadSetting is the error returned if an unknown setting is accessed

View Source
var ErrGuildNotExist = errors.New("guild does not exist")

ErrGuildNotExist is the error returned if a guild does not exist

View Source
var ErrTooManyRows = errors.New("too many rows")
View Source
var ErrTrialNotExist = errors.New("event does not exist")

ErrTrialNotExist is the error returned if a trial does not exist

Functions

This section is empty.

Types

type Guild

type Guild interface {
	GetName(ctx context.Context) string
	GetSettings(ctx context.Context) GuildSettings

	SetName(ctx context.Context, name string)
	SetSettings(ctx context.Context, s GuildSettings)

	Serialize(ctx context.Context) ([]byte, error)
}

Guild is the api for managing guild settings for a particular guild

type GuildAPI

type GuildAPI interface {
	NewTransaction(ctx context.Context, writable bool) (GuildAPITx, error)
	AllGuilds(ctx context.Context) ([]string, error)
}

GuildAPI is the api for managing guild settings transactions

func NewPgGuildAPI added in v0.26.0

func NewPgGuildAPI(ctx context.Context, db *pgxpool.Pool, c *telemetry.Census) (GuildAPI, error)

NewPgGuildAPI constructs a postgres-backed GuildAPI

type GuildAPITx

type GuildAPITx interface {
	Commit(ctx context.Context) error
	Rollback(ctx context.Context) error

	GetGuild(ctx context.Context, name string) (Guild, error)
	AddGuild(ctx context.Context, name string) (Guild, error)
	SaveGuild(ctx context.Context, guild Guild) error
}

GuildAPITx is the api for managing guild settings within a transaction

type GuildSettings

type GuildSettings struct {
	ControlSequence       string
	AnnounceChannel       string
	SignupChannel         string
	AdminChannel          string
	AnnounceTo            string
	ShowAfterSignup       string
	ShowAfterWithdraw     string
	HideReactionsAnnounce string
	HideReactionsShow     string
	AdminRoles            []string
	MessageColor          string
	ErrorColor            string
	// contains filtered or unexported fields
}

GuildSettings is the set of configuration settings for a guild

func GetSettings added in v0.1.3

func GetSettings(ctx context.Context, gapi GuildAPI, gid snowflake.Snowflake) (GuildSettings, error)

GetSettings is a wrapper to get the configuration settings for a guild

NOTE: this cannot be called after another transaction has been started

func (*GuildSettings) GetSettingString

func (s *GuildSettings) GetSettingString(ctx context.Context, name string) (string, error)

GetSettingString gets the value of a setting

func (*GuildSettings) PrettyString

func (s *GuildSettings) PrettyString(ctx context.Context) string

PrettyString returns a multi-line string describing the settings

func (*GuildSettings) SetSettingString

func (s *GuildSettings) SetSettingString(ctx context.Context, name, val string) error

SetSettingString sets the value of a setting

type PgGuildAPITx added in v0.27.0

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

func (*PgGuildAPITx) AddGuild added in v0.27.0

func (p *PgGuildAPITx) AddGuild(ctx context.Context, name string) (Guild, error)

func (*PgGuildAPITx) Commit added in v0.27.0

func (p *PgGuildAPITx) Commit(ctx context.Context) error

func (*PgGuildAPITx) GetGuild added in v0.27.0

func (p *PgGuildAPITx) GetGuild(ctx context.Context, name string) (Guild, error)

func (*PgGuildAPITx) GetGuildPg added in v0.27.0

func (p *PgGuildAPITx) GetGuildPg(ctx context.Context, name string) (Guild, error)

func (*PgGuildAPITx) Rollback added in v0.27.0

func (p *PgGuildAPITx) Rollback(ctx context.Context) error

func (*PgGuildAPITx) SaveGuild added in v0.27.0

func (p *PgGuildAPITx) SaveGuild(ctx context.Context, guild Guild) error

type RoleCount

type RoleCount interface {
	GetRole(ctx context.Context) string
	GetCount(ctx context.Context) uint64
	GetEmoji(ctx context.Context) string
	Index() int
}

RoleCount is the api for managing a role in a trial

type RoleCountSlice added in v0.25.0

type RoleCountSlice []RoleCount

func (RoleCountSlice) Len added in v0.25.0

func (s RoleCountSlice) Len() int

func (RoleCountSlice) Less added in v0.25.0

func (s RoleCountSlice) Less(i, j int) bool

func (RoleCountSlice) Swap added in v0.25.0

func (s RoleCountSlice) Swap(i, j int)

type Trial

type Trial interface {
	GetName(ctx context.Context) string
	GetTime(ctx context.Context) string
	GetDescription(ctx context.Context) string
	GetAnnounceTo(ctx context.Context) string
	GetAnnounceChannel(ctx context.Context) string
	GetSignupChannel(ctx context.Context) string
	GetState(ctx context.Context) TrialState
	GetSignups(ctx context.Context) []TrialSignup
	GetRoleCounts(ctx context.Context) []RoleCount
	GetRoleOrder(ctx context.Context) []string
	HideReactionsAnnounce(ctx context.Context) bool
	HideReactionsShow(ctx context.Context) bool
	PrettySettings(ctx context.Context) string

	SetName(ctx context.Context, name string)
	SetTime(ctx context.Context, t string)
	SetDescription(ctx context.Context, d string)
	SetAnnounceTo(ctx context.Context, val string)
	SetAnnounceChannel(ctx context.Context, val string)
	SetSignupChannel(ctx context.Context, val string)
	SetState(ctx context.Context, state TrialState)
	AddSignup(ctx context.Context, name, role string)
	RemoveSignup(ctx context.Context, name string)
	SetRoleCount(ctx context.Context, name, emoji string, ct uint64)
	RemoveRole(ctx context.Context, name string)
	SetRoleOrder(ctx context.Context, ord []string)
	SetHideReactionsAnnounce(ctx context.Context, val string) error
	SetHideReactionsShow(ctx context.Context, val string) error

	ClearSignups(ctx context.Context)

	Serialize(ctx context.Context) ([]byte, error)
}

Trial is the api for managing a particular trial

type TrialAPI

type TrialAPI interface {
	NewTransaction(ctx context.Context, guild string, writable bool) (TrialAPITx, error)
}

TrialAPI is the API for managing trials transactions

func NewPgTrialAPI added in v0.26.0

func NewPgTrialAPI(db *pgxpool.Pool, c *telemetry.Census) (TrialAPI, error)

NewPgTrialAPI constructs a boltDB-backed TrialAPI

type TrialAPITx

type TrialAPITx interface {
	Commit(ctx context.Context) error
	Rollback(ctx context.Context) error

	GetTrial(ctx context.Context, name string) (Trial, error)
	AddTrial(ctx context.Context, name string) (Trial, error)
	SaveTrial(ctx context.Context, trial Trial) error
	DeleteTrial(ctx context.Context, name string) error

	GetTrials(ctx context.Context) []Trial
}

TrialAPITx is the api for managing trials within a transaction

type TrialSignup

type TrialSignup interface {
	GetName(ctx context.Context) string
	GetRole(ctx context.Context) string
}

TrialSignup is the api for managing a signup for a trial

type TrialState

type TrialState string

TrialState represents the state of a trial

Jump to

Keyboard shortcuts

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