Documentation ¶
Index ¶
Constants ¶
const TargetType = "tg_user"
TargetType is the identifier used for events targeting a User.
Variables ¶
var ( ErrInvalidUser = errors.New("invalid user") ErrNotFound = errors.New("user not found") )
Common errors for User service implementations and validations.
Functions ¶
func IsInvalidUser ¶
IsInvalidUser indicates if err is ErrInvalidUser.
Types ¶
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error wraps common User errors.
type Image ¶
type Image struct { URL string `json:"url"` Type string `json:"type"` Height int `json:"height"` Width int `json:"width"` }
Image represents a user image asset.
type List ¶
type List []*User
List is a collection of users.
func ListFromIDs ¶
ListFromIDs gathers a user collection from the Service for the given ids.
type Map ¶
Map is a user collection with their id as index.
func MapFromIDs ¶
MapFromIDs return a populated user map for the given list of ids.
type Metadata ¶
type Metadata map[string]interface{}
Metadata is a bucket to provide additional user information.
type QueryOptions ¶
type QueryOptions struct { Before uint64 CustomIDs []string Deleted *bool Emails []string Firstnames []string Enabled *bool IDs []uint64 Lastnames []string Limit int Offset uint Query string SocialIDs map[string][]string Usernames []string }
QueryOptions is used to narrow-down user queries.
type Service ¶
type Service interface { service.Lifecycle Count(namespace string, opts QueryOptions) (int, error) Put(namespace string, user *User) (*User, error) PutLastRead(namespace string, userID uint64, lastRead time.Time) error Query(namespace string, opts QueryOptions) (List, error) Search(namespace string, opts QueryOptions) (List, error) }
Service for user interactions.
func MemService ¶
func MemService() Service
MemService returns a memory based Service implementation.
func PostgresService ¶
PostgresService returns a Postgres based Service implementation.
type ServiceMiddleware ¶
ServiceMiddleware is a chainable behaviour modifier for Service.
func InstrumentMiddleware ¶
func InstrumentMiddleware( component, store string, errCount kitmetrics.Counter, opCount kitmetrics.Counter, opLatency *prometheus.HistogramVec, ) ServiceMiddleware
InstrumentMiddleware observes key apsects of Service operations and exposes Prometheus metrics.
func LogMiddleware ¶
func LogMiddleware(logger log.Logger, store string) ServiceMiddleware
LogMiddleware gien a Logger wraps the next Service with logging capabilities.
type User ¶
type User struct { About string `json:"about"` CustomID string `json:"custom_id,omitempty"` Deleted bool `json:"deleted"` Enabled bool `json:"enabled"` Email string `json:"email,omitempty"` Firstname string `json:"first_name"` FollowerCount int `json:"-"` FollowingCount int `json:"-"` FriendCount int `json:"-"` ID uint64 `json:"id"` Images map[string]Image `json:"images,omitempty"` IsFollower bool `json:"-"` IsFollowing bool `json:"-"` IsFriend bool `json:"-"` Lastname string `json:"last_name"` LastRead time.Time `json:"-"` Metadata Metadata `json:"metadata"` Password string `json:"password"` Private *Private `json:"private,omitempty"` SessionToken string `json:"-"` SocialIDs map[string]string `json:"social_ids,omitempty"` URL string `json:"url,omitempty"` Username string `json:"user_name,omitempty"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` }
User is the representation of a customer of an app.