Documentation
¶
Index ¶
- type Backend
- func (b *Backend) Clear(ctx context.Context, pollID int) error
- func (b *Backend) ClearAll(ctx context.Context) error
- func (b *Backend) Close()
- func (b *Backend) LiveVotes(ctx context.Context) (map[int]map[int][]byte, error)
- func (b *Backend) Migrate(ctx context.Context) error
- func (b *Backend) Start(ctx context.Context, pollID int) error
- func (b *Backend) Stop(ctx context.Context, pollID int) ([][]byte, []int, error)
- func (b *Backend) String() string
- func (b *Backend) Vote(ctx context.Context, pollID int, userID int, object []byte) error
- func (b *Backend) Wait(ctx context.Context)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Backend ¶
type Backend struct {
// contains filtered or unexported fields
}
Backend holds the state of the backend.
Has to be initializes with New().
func (*Backend) ClearAll ¶
ClearAll removes all vote related data from postgres.
It does this by dropping vote vote-schema. If other services would write thinks in this schema or hava a relation to this schema, then this would also delete this tables.
Since the schema is deleted and afterwards recreated this command can also be used, if the db-schema has changed. It is kind of a migration.
func (*Backend) Close ¶
func (b *Backend) Close()
Close closes all connections. It blocks, until all connection are closed.
func (*Backend) LiveVotes ¶
LiveVotes returns all votes from each user.
This this is impossible for the current implementation, it only returns nil for each vote.
func (*Backend) Stop ¶
Stop ends a poll and returns all vote objects and users who have voted.
If an transaction error happens, the poll is stopped again. This is done until either the poll is stopped or the given context is canceled.