token

package module
v0.0.0-...-ffc28f4 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTokenNotFound  = errors.New(`token not found`)
	ErrTokenIsEmpty   = errors.New(`parameter "token" is empty`)
	ErrTokenIsExpired = errors.New(`token is expired`)
)

Functions

This section is empty.

Types

type External

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

func NewExternal

func NewExternal(dsn string) *External

func (*External) Close

func (ts *External) Close() error

func (*External) Get

func (ts *External) Get(id string) (*Token, error)

func (*External) Init

func (ts *External) Init() error

func (*External) Set

func (ts *External) Set(t *Token) error

type InMemory

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

func NewInMemory

func NewInMemory(dsn string) *InMemory

func (*InMemory) Close

func (ts *InMemory) Close() error

func (*InMemory) Get

func (ts *InMemory) Get(id string) (*Token, error)

func (*InMemory) Init

func (ts *InMemory) Init() error

func (*InMemory) Set

func (ts *InMemory) Set(t *Token) error

type Metric

type Metric struct {
	Request uint64
	Success uint64
	Error   uint64
	Last    time.Time
}

type Storage

type Storage interface {
	Init() error
	Close() error

	Get(id string) (*Token, error)
	Set(*Token) error
}

type Token

type Token struct {
	ID string

	Created time.Time
	Expired time.Time

	Access  []string
	Account uint64
}

func (*Token) IsExpired

func (t *Token) IsExpired() bool

Jump to

Keyboard shortcuts

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