server

package
v0.0.0-...-677ce44 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Model

type Model struct {
	*rpc.Token
	ID      pr.ObjectID `bson:"_id"`
	Email   string      `validator:"email"`
	Expires time.Time
}

Model represents a model to store a token.

func (*Model) GenerateToken

func (me *Model) GenerateToken(size int, txtMap ...string) (err error)

GenerateToken generats a new token for Token.Token

type Server

type Server struct {
	*timeout.Timeout

	Now       func() time.Time
	Validator *vld.Validate
	// contains filtered or unexported fields
}

Server is a Token RPC Implementation structure.

func New

func New(
	adapter adapter.IAdapter,
	tokSize int,
	maxAge time.Duration,
	opTimeout time.Duration,
	randomTxtSeed ...string,
) *Server

New creates a new Token RPC Server Instance. If randomTxtSeed is empty/nil/zero-value, this service will generate random token from ascii letters. i.e. the generated token will be matched with [a-zA-Z0-9]{tokSize}

func (*Server) CleanRottedToken

func (me *Server) CleanRottedToken()

CleanRottedToken removes rotted token from the DB.

func (*Server) Pop

func (me *Server) Pop(
	ctx context.Context, tok *rpc.Token,
) (out *rpc.Token, err error)

Pop token.

func (*Server) Push

func (me *Server) Push(ctx context.Context, tok *rpc.Token) (
	ret *rpc.Token, err error,
)

Push issues token id and store & return it.

Jump to

Keyboard shortcuts

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