uexky

package
v0.0.0-...-1dc691d Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetCache

func GetCache(u *Uexky, key string, value interface{}) (bool, error)

GetCache ...

func NewRedisPool

func NewRedisPool() *redis.Pool

NewRedisPool ...

func SetCache

func SetCache(u *Uexky, key string, value interface{}, expire int) error

SetCache ...

Types

type Auth

type Auth interface {
	IsSignedIn() bool
	RequireSignedIn() error
	Email() string
	CheckPriority(action, target string) (bool, error)
}

Auth ...

type Flow

type Flow interface {
	CostQuery(count int) error
	CostMut(count int) error
	Remaining() string
}

Flow ...

type FlowImpl

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

FlowImpl manage tool

func NewUexkyFlow

func NewUexkyFlow(u *Uexky, ip, email string) *FlowImpl

NewUexkyFlow make a new Flow, and add to Uexky

func (*FlowImpl) CostMut

func (flow *FlowImpl) CostMut(count int) error

CostMut ...

func (*FlowImpl) CostQuery

func (flow *FlowImpl) CostQuery(count int) error

CostQuery ...

func (*FlowImpl) Remaining

func (flow *FlowImpl) Remaining() string

Remaining : ip-query, ip-mut[, email-query, email-mut]

type FlowMock

type FlowMock struct{}

FlowMock ...

func NewMockFlow

func NewMockFlow(u *Uexky) *FlowMock

NewMockFlow ...

func (*FlowMock) CostMut

func (flow *FlowMock) CostMut(count int) error

CostMut ...

func (*FlowMock) CostQuery

func (flow *FlowMock) CostQuery(count int) error

CostQuery ...

func (*FlowMock) Remaining

func (flow *FlowMock) Remaining() string

Remaining ...

type Mongo

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

Mongo ...

func ConnectMongodb

func ConnectMongodb() *Mongo

ConnectMongodb ...

func (*Mongo) C

func (m *Mongo) C(name string) *mgo.Collection

C return collection

func (*Mongo) Close

func (m *Mongo) Close()

Close ...

func (*Mongo) Copy

func (m *Mongo) Copy() *Mongo

Copy ...

func (*Mongo) DB

func (m *Mongo) DB() *mgo.Database

DB ...

type Pool

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

Pool store global data for Frame

func InitPool

func InitPool() *Pool

InitPool ...

func (*Pool) NewUexky

func (p *Pool) NewUexky() *Uexky

NewUexky Make a new Uexky

func (*Pool) Push

func (p *Pool) Push(ctx context.Context) (context.Context, func())

Push an uexky object to context

type Redis

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

Redis ...

func NewRedis

func NewRedis(pool *redis.Pool) *Redis

NewRedis ...

func (*Redis) Do

func (r *Redis) Do(commandName string, args ...interface{}) (reply interface{}, err error)

Do ...

type Uexky

type Uexky struct {
	Mongo *Mongo
	Redis *Redis
	Auth  Auth
	Flow  Flow
}

Uexky is context for http request

func Pop

func Pop(ctx context.Context) *Uexky

Pop an uexky from context, if don't find uexky, will panic

func (*Uexky) Close

func (u *Uexky) Close()

Close ...

Jump to

Keyboard shortcuts

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