ffuser

package
v0.18.6 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2021 License: MIT Imports: 0 Imported by: 7

Documentation

Overview

Package ffuser defines the go-feature-flag model for user properties.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type User

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

A User contains specific attributes of a user browsing your site. The only mandatory property is the Key, which must uniquely identify each user. For authenticated users, this may be a username or e-mail address. For anonymous users, this could be an IP address or session ID.

User fields are immutable and can be accessed only via getter methods. To construct a User, use either a simple constructor (NewUser, NewAnonymousUser) or the builder pattern with NewUserBuilder.

func NewAnonymousUser

func NewAnonymousUser(key string) User

NewAnonymousUser creates a new anonymous user identified by the given key.

func NewUser

func NewUser(key string) User

NewUser creates a new user identified by the given key.

func (*User) GetCustom

func (u *User) GetCustom() map[string]interface{}

GetCustom return all the custom properties of a user.

func (*User) GetKey

func (u *User) GetKey() string

GetKey return the unique key for the user.

func (*User) IsAnonymous

func (u *User) IsAnonymous() bool

IsAnonymous return if the user is anonymous or not.

type UserBuilder

type UserBuilder interface {
	Anonymous(bool) UserBuilder
	AddCustom(string, interface{}) UserBuilder
	Build() User
}

UserBuilder is a builder to create a User.

func NewUserBuilder

func NewUserBuilder(key string) UserBuilder

NewUserBuilder constructs a new UserBuilder, specifying the user key.

For authenticated users, the key may be a username or e-mail address. For anonymous users, this could be an IP address or session ID.

Jump to

Keyboard shortcuts

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