memory

package
v0.0.0-...-d267b0f Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package memory implements the vote.Backend interface.

All data are saved in memory.

Index

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 is a vote backend that holds the data in memory.

func New

func New() *Backend

New initializes a new memory.Backend.

func (*Backend) AssertUserHasVoted

func (b *Backend) AssertUserHasVoted(t *testing.T, pollID, userID int)

AssertUserHasVoted is a method for the tests to check, if a user has voted.

func (*Backend) Clear

func (b *Backend) Clear(ctx context.Context, pollID int) error

Clear removes all data for a poll.

func (*Backend) ClearAll

func (b *Backend) ClearAll(ctx context.Context) error

ClearAll removes all data for all polls.

func (*Backend) LiveVotes

func (b *Backend) LiveVotes(ctx context.Context) (map[int]map[int][]byte, error)

LiveVotes returns all votes from each user. Returns nil on non named votes.

func (*Backend) Start

func (b *Backend) Start(ctx context.Context, pollID int) error

Start opens opens a poll.

func (*Backend) Stop

func (b *Backend) Stop(ctx context.Context, pollID int) ([][]byte, []int, error)

Stop stopps a poll.

func (*Backend) String

func (b *Backend) String() string

func (*Backend) Vote

func (b *Backend) Vote(ctx context.Context, pollID int, userID int, vote []byte) error

Vote saves a vote.

Jump to

Keyboard shortcuts

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