confie

package
v0.0.0-...-5b70f3c Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotMatched = errors.New("confie: code not matched")

ErrNotMatched occurs when code is not matched

Functions

This section is empty.

Types

type Config

type Config struct {
	// Storage is a code center
	Storage
}

Config defines the config for confie module

type Envoy

type Envoy struct {
	// Sender is embedded for sending code
	Sender
	// contains filtered or unexported fields
}

Envoy can generate code and send to a specific address

func Call

func Call(name ...string) *Envoy

Call returns a named envoy

func (*Envoy) Make

func (e *Envoy) Make(address, key string) (err error)

Make generates code and sends it

func (*Envoy) Verify

func (e *Envoy) Verify(key, code string) error

Verify validates the code related with the key. ErrNotMatched will be returned if code is not matched.

type Module

type Module struct {
	dawn.Module
	*Config
	// contains filtered or unexported fields
}

func New

func New(c ...*Config) *Module

New returns the Module

func (*Module) Init

func (m *Module) Init() dawn.Cleanup

func (*Module) RegisterRoutes

func (m *Module) RegisterRoutes(router fiber.Router)

func (*Module) String

func (m *Module) String() string

type Sender

type Sender interface {
	// Send delivers code to the address
	Send(address, code string) error

	// Close releases resource if needed
	Close() error
}

Sender defines an interface to send code with expiration

type Storage

type Storage interface {
	// Get retrieves code from the storage for the given key.
	Get(key string) ([]byte, error)
	// Set stores code in storage with given ttl
	Set(key string, value []byte, ttl time.Duration) error
	// Delete removes code in storage
	Delete(key string) error
}

Storage defines behaviors to manage sent code

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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