services

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

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

Go to latest
Published: Apr 20, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRedisRingOptions

func NewRedisRingOptions(opts ...map[string]interface{}) *redis.RingOptions

Types

type AnyGetter

type AnyGetter struct {
	Handler func(data interface{}) func(v interface{}) bool
	Next    func(v interface{}) bool
}

func (*AnyGetter) IsOk

func (an *AnyGetter) IsOk() bool

func (*AnyGetter) Result

func (an *AnyGetter) Result(v interface{}) bool

type CacheItemFunc

type CacheItemFunc func() (interface{}, error)

type CacheMarshalHandler

type CacheMarshalHandler func(interface{}) ([]byte, error)

type CacheService

type CacheService struct {
	Close context.CancelFunc
	// contains filtered or unexported fields
}

func GetCacheServices

func GetCacheServices(config map[string]interface{}) *CacheService

func (*CacheService) Cache

func (service *CacheService) Cache(key string, value interface{}, args ...interface{})

func (*CacheService) CacheItem

func (service *CacheService) CacheItem(item *cache.Item)

func (*CacheService) Delete

func (service *CacheService) Delete(key ...string)

func (*CacheService) Exists

func (service *CacheService) Exists(key string) bool

func (*CacheService) Get

func (service *CacheService) Get(key string) (interface{}, error)

func (*CacheService) GetAnyType

func (service *CacheService) GetAnyType(key string, v interface{}) error

func (*CacheService) GetClose

func (service *CacheService) GetClose() context.CancelFunc

func (*CacheService) GetCtx

func (service *CacheService) GetCtx() context.Context

func (*CacheService) GetMarshal

func (service *CacheService) GetMarshal() CacheMarshalHandler

func (*CacheService) GetUnMarshal

func (service *CacheService) GetUnMarshal() CacheUnmarshalHandler

func (*CacheService) NewItem

func (service *CacheService) NewItem(key string, value interface{}, options ...interface{}) *cache.Item

func (*CacheService) Set

func (service *CacheService) Set(key, value string, expire ...time.Duration)

func (*CacheService) SetCtx

func (service *CacheService) SetCtx(ctx context.Context, close ...context.CancelFunc)

func (*CacheService) SetMarshal

func (service *CacheService) SetMarshal(fn CacheMarshalHandler) *CacheService

func (*CacheService) SetUnMarshal

func (service *CacheService) SetUnMarshal(fn CacheUnmarshalHandler) *CacheService

type CacheUnmarshalHandler

type CacheUnmarshalHandler func([]byte, interface{}) error

type Closer

type Closer interface {
	Close()
}

type Getter

type Getter struct {
	Handler func(map[string]interface{}) func(v interface{}) bool
	Next    func(v interface{}) bool
}

func (*Getter) IsOk

func (g *Getter) IsOk() bool

func (*Getter) Result

func (g *Getter) Result(v interface{}) bool

type ICacheService

type ICacheService interface {
	Set(key, value string, expire ...time.Duration)
	Get(key string) (interface{}, error)
	GetAnyType(string, interface{}) error
	Delete(key ...string)
	Exists(key string) bool
}

func GetCacheService

func GetCacheService(client ...*redis.Ring) ICacheService

type ILoginService

type ILoginService interface {
	Auth(string) Base.IReturnAble
	LoginByEmail(email string, password string) Base.IReturnAble
	LoginByMobile(mobile string, password string) Base.IReturnAble
	LoginByMobileSmsCode(mobile string, code string) Base.IReturnAble
	LoginByAccountPassword(username string, password string) Base.IReturnAble
}

type IStore

type IStore interface {
	Set(key, value string, expire ...time.Duration)
	Get(key string) (string, bool)
	Delete(key string)
	Destroy()
}

func NewStore

func NewStore() IStore

type IStoreManager

type IStoreManager interface {
	Store(name string) (IStore, bool)
}

func GetStoreManager

func GetStoreManager() IStoreManager

func NewStoreManager

func NewStoreManager() IStoreManager

type ITokenOptions

type ITokenOptions interface {
	Expire() time.Duration // 过期时长
	Key() []string         // 配置主要键生成 key
	Domain() []string      // token 颁发域名列表
	Publish() string       // token 生成域名
	Scope() string         // 作用域
	IdentityKey() string   // 身份
}

func NewTokenOptions

func NewTokenOptions(data ...map[string]interface{}) ITokenOptions

type ITokenService

type ITokenService interface {
	Token(data interface{}, option ...ITokenOptions) (token ITokenType)                  // 创建 token
	Data(token string, option ...ITokenOptions) (data map[string]interface{}, err error) // 输出token 数据对象
	Exists(token string) bool                                                            // token 是否存在
	Expired(token string) bool                                                           // token 是否过期
	TransformType(token string, ty interface{}) error                                    // token 对应数绑定struct
	Store(string, ITokenOptions) string                                                  // 存储 token对应信息 返回 key
	Get(string) (ITokenType, error)                                                      // 通过 token 获取信息对象
	Delete(string)                                                                       // 删除token
}

func GetUserTokenService

func GetUserTokenService() ITokenService

func NewTokenService

func NewTokenService() ITokenService

type ITokenType

type ITokenType interface {
	ToString() string                    // 输出 token
	Exists() bool                        // token 是否存在
	CreateAt() time.Time                 // 创建时间
	Expired() bool                       // 是否已过期
	Data() (interface{}, bool)           //  输出token 数据
	Map() (map[string]interface{}, bool) //  输出token 数据
	Set(string)                          //  设置 token
	Domain() []string                    // token 颁发域名列表
	Publish() string                     // token 生成域名
	Scope() string                       // 作用域
	Identity() string                    // 身份
}

func DecodeToken

func DecodeToken(token string) (ITokenType, error)

func EncodeToken

func EncodeToken(data string, options ITokenOptions) ITokenType

func NewTokenType

func NewTokenType(token string) ITokenType

type IUserService

type IUserService interface {
	LoginByAccountPwd(username string, password string) Base.IReturnAble
}

func GetUserService

func GetUserService() IUserService

func NewUserService

func NewUserService(repo repositories.IUserRepository) IUserService

type LoginService

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

func (*LoginService) Auth

func (*LoginService) LoginByAccountPassword

func (l *LoginService) LoginByAccountPassword(username string, password string) Base.IReturnAble

func (*LoginService) LoginByEmail

func (l *LoginService) LoginByEmail(email string, password string) Base.IReturnAble

func (*LoginService) LoginByMobile

func (l *LoginService) LoginByMobile(mobile string, password string) Base.IReturnAble

func (*LoginService) LoginByMobileSmsCode

func (l *LoginService) LoginByMobileSmsCode(mobile string, code string) Base.IReturnAble

type MapAny

type MapAny map[string]interface{}

type Store

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

func (*Store) Delete

func (s *Store) Delete(key string)

func (*Store) Destroy

func (s *Store) Destroy()

func (*Store) Get

func (s *Store) Get(key string) (string, bool)

func (*Store) GetConn

func (s *Store) GetConn() interface{}

func (*Store) Set

func (s *Store) Set(key, value string, expire ...time.Duration)

type StoreManager

type StoreManager struct {
	Config Base.ConfigureFace
}

func (*StoreManager) Init

func (manager *StoreManager) Init() *StoreManager

func (*StoreManager) Store

func (manager *StoreManager) Store(name string) (IStore, bool)

type TokenOptions

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

token 可选项

func (*TokenOptions) Domain

func (opt *TokenOptions) Domain() []string

func (*TokenOptions) Expire

func (opt *TokenOptions) Expire() time.Duration

func (*TokenOptions) IdentityKey

func (opt *TokenOptions) IdentityKey() string

func (*TokenOptions) Key

func (opt *TokenOptions) Key() []string

func (*TokenOptions) Publish

func (opt *TokenOptions) Publish() string

func (*TokenOptions) Scope

func (opt *TokenOptions) Scope() string

type TokenService

type TokenService struct {
	S IStore
}

func (*TokenService) Data

func (service *TokenService) Data(token string, option ...ITokenOptions) (data map[string]interface{}, err error)

func (*TokenService) Delete

func (service *TokenService) Delete(key string)

func (*TokenService) Exists

func (service *TokenService) Exists(token string) bool

func (*TokenService) Expired

func (service *TokenService) Expired(token string) bool

func (*TokenService) Get

func (service *TokenService) Get(key string) (ITokenType, error)

func (*TokenService) Store

func (service *TokenService) Store(data string, options ITokenOptions) string

func (*TokenService) Token

func (service *TokenService) Token(data interface{}, option ...ITokenOptions) (token ITokenType)

func (*TokenService) TransformType

func (service *TokenService) TransformType(token string, ty interface{}) error

type TokenType

type TokenType struct {
	Keys          []string
	PublishDomain string
	Domains       []string
	StoreKey      string
	ExpiredAt     time.Time
	IdentityStr   string
	ScopeKey      string
	// contains filtered or unexported fields
}

token 对象

func (*TokenType) CreateAt

func (token *TokenType) CreateAt() time.Time

func (*TokenType) Data

func (token *TokenType) Data() (interface{}, bool)

func (*TokenType) Domain

func (token *TokenType) Domain() []string

func (*TokenType) Exists

func (token *TokenType) Exists() bool

func (*TokenType) Expired

func (token *TokenType) Expired() bool

func (*TokenType) Identity

func (token *TokenType) Identity() string

func (*TokenType) Map

func (token *TokenType) Map() (map[string]interface{}, bool)

func (*TokenType) Publish

func (token *TokenType) Publish() string

func (*TokenType) Scope

func (token *TokenType) Scope() string

func (*TokenType) Set

func (token *TokenType) Set(t string)

func (*TokenType) ToString

func (token *TokenType) ToString() string

type UserService

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

func (*UserService) LoginByAccountPwd

func (u *UserService) LoginByAccountPwd(username string, password string) Base.IReturnAble

Jump to

Keyboard shortcuts

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