storage

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2019 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 ErrTrialNotExist = errors.New("trial 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 NewBoltGuildAPI

func NewBoltGuildAPI(ctx context.Context, db *bolt.DB, c *census.OpenCensus) (GuildAPI, error)

NewBoltGuildAPI constructs a boltDB-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
	AdminRole         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 RoleCount

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

RoleCount is the api for managing a role in a trial

type Trial

type Trial interface {
	GetName(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
	PrettySettings(ctx context.Context) string

	SetName(ctx context.Context, name 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)

	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 NewBoltTrialAPI

func NewBoltTrialAPI(db *bolt.DB, c *census.OpenCensus) (TrialAPI, error)

NewBoltTrialAPI 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