admin

package
v1.7.1 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2021 License: MIT Imports: 5 Imported by: 0

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

type EventType int

EventType indicates type of the event

const (
	EvCreate EventType = iota
	EvDelete
	EvUpdate
	EvVote
)

enum of all event types

type RPC

type RPC struct {
	jrpc.Client
}

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

func (*RPC) Admins

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

Admins returns list of admin's ids for given site

func (*RPC) Email

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

Email gets email address for given site

func (*RPC) Enabled

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

Enabled returns true if allowed

func (*RPC) Key

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

Key returns the key, same for all sites

func (*RPC) OnEvent

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, adminIDs []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 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

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

Enabled if always true for StaticStore

func (*StaticStore) Key

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

Key returns static key, same for all sites

func (*StaticStore) OnEvent

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

OnEvent doesn nothing for StaticStore

type Store

type Store interface {
	Key(siteID string) (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