storage

package
v0.9.5 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2018 License: MIT Imports: 8 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() string
	GetSettings() GuildSettings

	SetName(name string)
	SetSettings(s GuildSettings)

	Serialize() ([]byte, error)
}

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

type GuildAPI

type GuildAPI interface {
	NewTransaction(writable bool) (GuildAPITx, error)
}

GuildAPI is the api for managing guild settings transactions

func NewBoltGuildAPI

func NewBoltGuildAPI(db *bolt.DB) (GuildAPI, error)

NewBoltGuildAPI constructs a boltDB-backed GuildAPI

type GuildAPITx

type GuildAPITx interface {
	Commit() error
	Rollback() error

	GetGuild(name string) (Guild, error)
	AddGuild(name string) (Guild, error)
	SaveGuild(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
}

GuildSettings is the set of configuration settings for a guild

func GetSettings added in v0.1.3

func GetSettings(gapi GuildAPI, gid snowflake.Snowflake) (s GuildSettings, err 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(name string) (string, error)

GetSettingString gets the value of a setting

func (*GuildSettings) PrettyString

func (s *GuildSettings) PrettyString() string

PrettyString returns a multi-line string describing the settings

func (*GuildSettings) SetSettingString

func (s *GuildSettings) SetSettingString(name, val string) error

SetSettingString sets the value of a setting

type RoleCount

type RoleCount interface {
	GetRole() string
	GetCount() uint64
	GetEmoji() string
}

RoleCount is the api for managing a role in a trial

type Trial

type Trial interface {
	GetName() string
	GetDescription() string
	GetAnnounceChannel() string
	GetSignupChannel() string
	GetState() TrialState
	GetSignups() []TrialSignup
	GetRoleCounts() []RoleCount

	SetName(name string)
	SetDescription(d string)
	SetAnnounceChannel(val string)
	SetSignupChannel(val string)
	SetState(state TrialState)
	AddSignup(name, role string)
	RemoveSignup(name string)
	SetRoleCount(name, emoji string, ct uint64)
	RemoveRole(name string)

	Serialize() ([]byte, error)
}

Trial is the api for managing a particular trial

type TrialAPI

type TrialAPI interface {
	NewTransaction(guild string, writable bool) (TrialAPITx, error)
}

TrialAPI is the API for managing trials transactions

func NewBoltTrialAPI

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

NewBoltTrialAPI constructs a boltDB-backed TrialAPI

type TrialAPITx

type TrialAPITx interface {
	Commit() error
	Rollback() error

	GetTrial(name string) (Trial, error)
	AddTrial(name string) (Trial, error)
	SaveTrial(trial Trial) error
	DeleteTrial(name string) error

	GetTrials() []Trial
}

TrialAPITx is the api for managing trials within a transaction

type TrialSignup

type TrialSignup interface {
	GetName() string
	GetRole() 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