userinfo

package
v0.0.0-...-736556e Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultEnvironment = "live"
	DefaultUsername    = "-"
	DefaultUserID      = "-1"
)

Default user values.

Variables

View Source
var (
	ErrNoConfig = fmt.Errorf("config must contain all fields")
	ErrNoUser   = fmt.Errorf("user not found")
)

Errors returned by this package.

Functions

This section is empty.

Types

type Config

type Config struct {
	Host        string `toml:"host" xml:"host" json:"host"`
	User        string `toml:"user" xml:"user" json:"user"`
	Pass        string `toml:"pass" xml:"pass" json:"-"`
	Name        string `toml:"name" xml:"name" json:"name"`
	*log.Logger `json:"-"`
}

Config to get user data from the mysql database.

type UI

type UI struct {
	*log.Logger
	// contains filtered or unexported fields
}

UI provides an interface to query a database for user info.

func New

func New(config *Config, metrics *exp.Metrics) (*UI, error)

New returns a User Info interface.

func (*UI) Close

func (u *UI) Close()

Close the database connection.

func (*UI) GetInfo

func (u *UI) GetInfo(ctx context.Context, requestKey string) (*UserInfo, error)

GetInfo returns a user's info from a mysql database.

func (*UI) GetServer

func (u *UI) GetServer(ctx context.Context, serverID string) (*UserInfo, error)

func (*UI) Open

func (u *UI) Open() error

Open a mysql database connection.

type UserInfo

type UserInfo struct {
	APIKey      string `json:"apiKey,omitempty"`
	Environment string `json:"environment"`
	Username    string `json:"username"`
	UserID      string `json:"userId"`
}

UserInfo is the data returned for each user request.

func DefaultUser

func DefaultUser() *UserInfo

DefaultUser returns an empty user with default values.

Jump to

Keyboard shortcuts

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