admin

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2021 License: MIT Imports: 5 Imported by: 16

Documentation

Overview

Package admin defines and implements store for admin-level data like secret key, list of admins and so on

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EventType added in v1.5.0

type EventType int

EventType indicates type of the event

const (
	EvCreate EventType = iota
	EvDelete
	EvUpdate
	EvVote
)

enum of all event types

type RPC added in v1.4.0

type RPC struct {
	jrpc.Client
}

RPC implements remote engine and delegates all Calls to remote http server

func (*RPC) Admins added in v1.4.0

func (r *RPC) Admins(siteID string) (ids []string, err error)

Admins returns list of admin's ids for given site

func (*RPC) Email added in v1.4.0

func (r *RPC) Email(siteID string) (email string, err error)

Email gets email address for given site

func (*RPC) Enabled added in v1.5.0

func (r *RPC) Enabled(siteID string) (ok bool, err error)

Enabled returns true if allowed

func (*RPC) Key added in v1.4.0

func (r *RPC) Key() (key string, err error)

Key returns the key, same for all sites

func (*RPC) OnEvent added in v1.5.0

func (r *RPC) OnEvent(siteID string, et EventType) error

OnEvent reacts (register) events about data modification

type StaticStore

type StaticStore struct {
	// contains filtered or unexported fields
}

StaticStore implements keys.Store with a single set of admins and email for all sites

func NewStaticKeyStore

func NewStaticKeyStore(key string) *StaticStore

NewStaticKeyStore is a shortcut for making StaticStore for key consumers only

func NewStaticStore

func NewStaticStore(key string, sites []string, admins []string, email string) *StaticStore

NewStaticStore makes StaticStore instance with given key

func (*StaticStore) Admins

func (s *StaticStore) Admins(string) (ids []string, err error)

Admins returns static list of admin's ids, the same for all sites

func (*StaticStore) Email

func (s *StaticStore) Email(string) (email string, err error)

Email gets static email address

func (*StaticStore) Enabled added in v1.5.0

func (s *StaticStore) Enabled(site string) (ok bool, err error)

Enabled if always true for StaticStore

func (*StaticStore) Key

func (s *StaticStore) Key() (key string, err error)

Key returns static key, same for all sites

func (*StaticStore) OnEvent added in v1.5.0

func (s *StaticStore) OnEvent(_ string, _ EventType) error

OnEvent doesn nothing for StaticStore

type Store

type Store interface {
	Key() (key string, err error)
	Admins(siteID string) (ids []string, err error)
	Email(siteID string) (email string, err error)
	Enabled(siteID string) (ok bool, err error)
	OnEvent(siteID string, et EventType) error
}

Store defines interface returning admins info for given site

Jump to

Keyboard shortcuts

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