Documentation
¶
Index ¶
- Constants
- type Store
- type StoreRepository
- func (repository *StoreRepository) Create(id uint16, token string) (*Store, error)
- func (repository *StoreRepository) Delete(store *Store) error
- func (repository *StoreRepository) GetById(id uint16) *Store
- func (repository *StoreRepository) RegisterMetricsTicks(tickManager server.TickManager)
- func (repository *StoreRepository) RotateToken(store *Store) error
- func (repository *StoreRepository) Save(store *Store) error
Constants ¶
const TOKEN_BYTES = 8
const TOKEN_LENGTH = 2 * TOKEN_BYTES
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Store ¶
type Store struct { Id uint16 `json:"id"` Token string `json:"token"` OwnerId uint64 `json:"ownerId" binding:"required"` SubmissionId uint64 `json:"submissionId"` // contains filtered or unexported fields }
func (*Store) Metrics ¶
func (store *Store) Metrics() *metrics.StoreSnapshot
type StoreRepository ¶
type StoreRepository struct { // Token -> Store (nearly all access is going to be reads identified by an access token, not an ID // even though we primarily use the ID internally instead, to avoid coupling persisted data to a token // which may change (as opposed to an ID which will not). Items map[string]*Store `json:"items"` // contains filtered or unexported fields }
StoreRepository is *not* thread-safe. In our use case mutations only ever happen via administrative actions, at most a few times *daily* and realistically never concurrently. In the edge case a store gets deleted during a read, even if the read call came in before the delete call, the deletion *may* happen before, causing the read request to fail to find the store and return with an error. If the read happens before the deletion, the read call stack will continue to hold a pointer to the Store even if it meanwhile gets removed from the Repository (which is fine). The maps are allocated on the heap and will be touched by the GC. Realistically we expect at most a few dozen up to a max of a few hundred stores to be present, so as long as this assumption holds true GC pauses should not be impacted in a meaningful manner.
func LoadStoreRepository ¶
func LoadStoreRepository(db *bolt.DB, bucketKey []byte) (*StoreRepository, error)
LoadStoreRepository creates a StoreRepository and populates it from the given bucket identified by its key in the backing storage.
func (*StoreRepository) Create ¶
func (repository *StoreRepository) Create(id uint16, token string) (*Store, error)
func (*StoreRepository) Delete ¶
func (repository *StoreRepository) Delete(store *Store) error
func (*StoreRepository) GetById ¶
func (repository *StoreRepository) GetById(id uint16) *Store
func (*StoreRepository) RegisterMetricsTicks ¶
func (repository *StoreRepository) RegisterMetricsTicks(tickManager server.TickManager)
func (*StoreRepository) RotateToken ¶
func (repository *StoreRepository) RotateToken(store *Store) error
func (*StoreRepository) Save ¶
func (repository *StoreRepository) Save(store *Store) error