external

package
v0.0.0-...-c59394f Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2017 License: Apache-2.0 Imports: 9 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultUserStoreMock = UserStoreMock{"test": 1}

DefaultUserStoreMock default mock UserStore

View Source
var Root = UserFunc(func(args ...interface{}) (int64, error) { return 1, nil })

Root for root user

Functions

This section is empty.

Types

type Etcd

type Etcd struct {
	*etcd.KV
	*etcd.Incrementer
}

Etcd for a UserStore using etcdkv

func NewEtcd

func NewEtcd(kv *etcd.KV) *Etcd

NewEtcd returns a new Etcd

func (*Etcd) CreateUserByUniqueID

func (e *Etcd) CreateUserByUniqueID(uniqueID string) (int64, error)

CreateUserByUniqueID creates a user with the given uniqueID

func (*Etcd) GetUserIDByUniqueID

func (e *Etcd) GetUserIDByUniqueID(uniqueID string) (int64, error)

GetUserIDByUniqueID gets one user using the uniqueID

type MySQL

type MySQL struct {
	*gorm.DB
}

MySQL wraps a mysql service

func NewMySQL

func NewMySQL() *MySQL

NewMySQL create a new mysql client

func NewSQLite

func NewSQLite() *MySQL

NewSQLite create a new mysql client

func (*MySQL) CreateUserByUniqueID

func (db *MySQL) CreateUserByUniqueID(uniqueID string) (int64, error)

CreateUserByUniqueID implements UserStore

func (*MySQL) GetUserIDByUniqueID

func (db *MySQL) GetUserIDByUniqueID(uniqueID string) (int64, error)

GetUserIDByUniqueID implements UserStore

type SQLite

type SQLite struct {
	*gorm.DB
}

SQLite wraps a mysql service

func (*SQLite) CreateUserByUniqueID

func (db *SQLite) CreateUserByUniqueID(uniqueID string) (int64, error)

CreateUserByUniqueID implements UserStore

func (*SQLite) GetUserIDByUniqueID

func (db *SQLite) GetUserIDByUniqueID(uniqueID string) (int64, error)

GetUserIDByUniqueID implements UserStore

type User

type User interface {
	ID(args ...interface{}) (int64, error)
}

User represents a user of sqs

type UserFunc

type UserFunc func(args ...interface{}) (int64, error)

UserFunc user function

func (UserFunc) ID

func (f UserFunc) ID(args ...interface{}) (int64, error)

ID implement User interface

type UserMySQL

type UserMySQL struct {
	gorm.Model
	UniqueID string `json:"unique_id"`
}

UserMySQL stores a user into MySQL

type UserSQLite

type UserSQLite struct {
	gorm.Model
	UniqueID string `json:"unique_id"`
}

UserSQLite stores a user into MySQL

type UserStore

type UserStore interface {
	GetUserIDByUniqueID(uniqueID string) (int64, error)
	CreateUserByUniqueID(uniqueID string) (int64, error)
}

UserStore for user storage

var DefaultUserStore UserStore

DefaultUserStore default store for user

type UserStoreMock

type UserStoreMock map[string]int64

UserStoreMock mock a user store with a map

func (UserStoreMock) CreateUserByUniqueID

func (u UserStoreMock) CreateUserByUniqueID(uniqueID string) (int64, error)

CreateUserByUniqueID implements UserStore

func (UserStoreMock) GetUserIDByUniqueID

func (u UserStoreMock) GetUserIDByUniqueID(uniqueID string) (int64, error)

GetUserIDByUniqueID implements UserStore

Jump to

Keyboard shortcuts

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