Documentation ¶
Overview ¶
Package userup provides functionality for logging events in the user service.
Index ¶
- func NewSessionID() string
- func UserSearchToUserQuery(usp *UserSearchParams) *userapi.UserQuery
- type Condition
- type Event
- type EventLogger
- type EventLoggerConfig
- type Integration
- type IntegrationsService
- func (is *IntegrationsService) AddIntegration(ctx context.Context, integration *Integration) (*Integration, error)
- func (is *IntegrationsService) Close()
- func (is *IntegrationsService) GetIntegration(ctx context.Context, name string) (*Integration, error)
- func (is *IntegrationsService) GetJobHistory(ctx context.Context, integrationName string) ([]*Job, error)
- func (is *IntegrationsService) JobUpdate(ctx context.Context, job *Job) error
- func (is *IntegrationsService) ListIntegrations(ctx context.Context) ([]*Integration, error)
- func (is *IntegrationsService) RemoveIntegration(ctx context.Context, name string) error
- func (is *IntegrationsService) UpdateIntegration(ctx context.Context, integration *Integration) (*Integration, error)
- type Job
- type Join
- type LogicalOperator
- type Order
- type Query
- type SessionEventQuery
- type SessionQuery
- type User
- type UserID
- type UserSearchParams
- type UserService
- func (us UserService) AddAttribute(ctx context.Context, id UserID, key string, value interface{}) error
- func (us UserService) AddSession(ctx context.Context, sessionKey string, sessionData map[string]interface{}) error
- func (us UserService) AddTrait(ctx context.Context, id UserID, key string, value interface{}) error
- func (us UserService) AddUser(ctx context.Context, user *User) (*User, error)
- func (us *UserService) Close()
- func (us UserService) DeleteAttribute(ctx context.Context, userId UserID, key string) error
- func (us UserService) DeleteTrait(ctx context.Context, userId UserID, key string) error
- func (us UserService) DeleteUser(ctx context.Context, id UserID) error
- func (us UserService) FindUser(ctx context.Context, usp *UserSearchParams) ([]*User, error)
- func (us UserService) GetSessionEvents(ctx context.Context, query *SessionEventQuery) ([]*userapi.Event, error)
- func (us UserService) GetSessions(ctx context.Context, query *SessionQuery) ([]*userapi.Session, error)
- func (us UserService) GetUser(ctx context.Context, id UserID) (*User, error)
- func (us UserService) GetUsersByEvents(ctx context.Context, types []string, sources []string, schemas []string, ...) ([]*User, error)
- func (us UserService) GetUsersByTraits(ctx context.Context, names []string, begin time.Time, end time.Time) ([]*User, error)
- func (us UserService) IdentifySession(ctx context.Context, sessionKey string, userID UserID) error
- func (us UserService) QueryAttributes(ctx context.Context, query *Query) (map[string]interface{}, error)
- func (us UserService) QueryEvents(ctx context.Context, query *Query) ([]Event, error)
- func (us UserService) QueryTraits(ctx context.Context, query *Query) (map[string]interface{}, error)
- func (us UserService) QueryUsers(ctx context.Context, query *Query) ([]*User, error)
- func (us UserService) SearchEvents(ctx context.Context, userId UserID, types []string, begin time.Time, ...) ([]Event, error)
- func (us UserService) SearchUserTraits(ctx context.Context, userId UserID, names []string, begin time.Time, ...) ([]interface{}, error)
- func (us UserService) UpdateUser(ctx context.Context, user *User) (*User, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewSessionID ¶
func NewSessionID() string
NewSessionID creates a new random ID for a session ID.
func UserSearchToUserQuery ¶
func UserSearchToUserQuery(usp *UserSearchParams) *userapi.UserQuery
Types ¶
type Condition ¶
type Condition map[string]interface{}
Condition represents a condition in a database query.
type EventLogger ¶
type EventLogger struct {
// contains filtered or unexported fields
}
EventLogger represents a logger for logging events in the user service.
func NewLogger ¶
func NewLogger(config EventLoggerConfig) EventLogger
NewLogger creates a new EventLogger with the specified configuration. It returns the created EventLogger.
type EventLoggerConfig ¶
type EventLoggerConfig struct { Source string // Source represents the source of the events. SpecVersion string // SpecVersion represents the version of the event specification. UserService *UserService // UserService represents the user service client. }
EventLoggerConfig represents the configuration for the EventLogger.
func NewLoggerConfig ¶
func NewLoggerConfig(source string, userService *UserService) EventLoggerConfig
NewLoggerConfig creates a new EventLoggerConfig with the specified source and UserService. It returns the created EventLoggerConfig.
type Integration ¶
type IntegrationsService ¶
type IntegrationsService struct {
// contains filtered or unexported fields
}
func NewIntegrationsClient ¶
func NewIntegrationsClient(uri string) (*IntegrationsService, error)
NewIntegrationsClient creates a new instance of the UserService Integrations client. It establishes a gRPC connection to the specified URI and returns the client. The URI should be in the format "host:port". If the connection cannot be established, an error is returned.
func (*IntegrationsService) AddIntegration ¶
func (is *IntegrationsService) AddIntegration(ctx context.Context, integration *Integration) (*Integration, error)
AddIntegration adds a new integration to the user service.
func (*IntegrationsService) Close ¶
func (is *IntegrationsService) Close()
func (*IntegrationsService) GetIntegration ¶
func (is *IntegrationsService) GetIntegration(ctx context.Context, name string) (*Integration, error)
func (*IntegrationsService) GetJobHistory ¶
func (*IntegrationsService) JobUpdate ¶
func (is *IntegrationsService) JobUpdate(ctx context.Context, job *Job) error
func (*IntegrationsService) ListIntegrations ¶
func (is *IntegrationsService) ListIntegrations(ctx context.Context) ([]*Integration, error)
func (*IntegrationsService) RemoveIntegration ¶
func (is *IntegrationsService) RemoveIntegration(ctx context.Context, name string) error
func (*IntegrationsService) UpdateIntegration ¶
func (is *IntegrationsService) UpdateIntegration(ctx context.Context, integration *Integration) (*Integration, error)
type Join ¶
type Join struct { Table string `json:"table"` // The name of the table to join. On string `json:"on"` // The join condition. Filter map[string]Condition `json:"filter,omitempty"` // Optional filter conditions for the join. }
Join represents a join operation in a database query.
type LogicalOperator ¶
type LogicalOperator string
LogicalOperator represents a logical operator used in query conditions.
type Order ¶
type Order struct { Field string `json:"field"` // The field to order by. Direction string `json:"direction"` // The direction of the ordering ("ASC" or "DESC"). }
Order specifies the ordering of the query results.
type Query ¶
type Query struct { Filter map[string]Condition `json:"filter"` // The filter conditions for the query. Select []string `json:"select,omitempty"` // The fields to select in the query. OrderBy []Order `json:"order_by,omitempty"` // The ordering of the query results. Limit int `json:"limit,omitempty"` // The maximum number of results to return. Offset int `json:"offset,omitempty"` // The offset of the query results. Joins []Join `json:"joins,omitempty"` // The join operations in the query. }
Query represents a database query.
type SessionEventQuery ¶
type SessionQuery ¶
type User ¶
type User struct { ID UserID Username string Attributes map[string]interface{} Traits map[string]interface{} }
func UserResponseToUser ¶
func UserResponseToUser(userResp *userapi.UserResponse) *User
type UserSearchParams ¶
type UserSearchParams struct { ID UserID Username string AttributeFilters []*userapi.AttributeFilter TraitFilters []*userapi.TraitFilter }
func (UserSearchParams) WithAttribute ¶
func (usp UserSearchParams) WithAttribute(name string, value interface{}, operator ...userapi.Operator) UserSearchParams
func (UserSearchParams) WithTrait ¶
func (usp UserSearchParams) WithTrait(name string, value interface{}, operator ...userapi.Operator) UserSearchParams
type UserService ¶
type UserService struct {
// contains filtered or unexported fields
}
func NewClient ¶
func NewClient(uri string) (*UserService, error)
NewClient creates a new instance of the UserService client. It establishes a gRPC connection to the specified URI and returns the client. The URI should be in the format "host:port". If the connection cannot be established, an error is returned.
func (UserService) AddAttribute ¶
func (us UserService) AddAttribute(ctx context.Context, id UserID, key string, value interface{}) error
AddAttribute adds an attribute to a user with the specified ID. It takes a context, user ID, attribute key, and attribute value as parameters. The attribute value can be of any type and will be converted to a structpb.Value. Returns an error if there was a problem adding the attribute.
func (UserService) AddSession ¶
func (UserService) AddTrait ¶
AddTrait adds a trait to a user identified by their ID. It takes a context, user ID, trait key, and trait value as parameters. The trait value can be of any type and will be converted to a structpb.Value. Returns an error if there was a problem adding the trait.
func (UserService) AddUser ¶
AddUser adds a new user to the user service. It takes a context and a pointer to a User struct as input. It returns a pointer to the created User and an error, if any.
func (*UserService) Close ¶
func (us *UserService) Close()
func (UserService) DeleteAttribute ¶
func (UserService) DeleteTrait ¶
func (UserService) DeleteUser ¶
func (us UserService) DeleteUser(ctx context.Context, id UserID) error
DeleteUser deletes a user by their ID.
func (UserService) FindUser ¶
func (us UserService) FindUser(ctx context.Context, usp *UserSearchParams) ([]*User, error)
func (UserService) GetSessionEvents ¶
func (us UserService) GetSessionEvents(ctx context.Context, query *SessionEventQuery) ([]*userapi.Event, error)
func (UserService) GetSessions ¶
func (us UserService) GetSessions(ctx context.Context, query *SessionQuery) ([]*userapi.Session, error)
func (UserService) GetUser ¶
GetUser retrieves a user by their ID. It makes a request to the user service API to fetch the user details. Returns the user object if found, otherwise returns an error.
func (UserService) GetUsersByEvents ¶
func (UserService) GetUsersByTraits ¶
func (UserService) IdentifySession ¶
func (UserService) QueryAttributes ¶
func (us UserService) QueryAttributes(ctx context.Context, query *Query) (map[string]interface{}, error)
QueryAttributes queries the attributes of a user based on the provided query. It takes a context.Context and a *Query as input parameters. It returns a map[string]interface{} containing the attributes of the user and an error if any.
func (UserService) QueryEvents ¶
QueryEvents queries events based on the provided query parameters. It returns a slice of Event objects and an error if any.
func (UserService) QueryTraits ¶
func (us UserService) QueryTraits(ctx context.Context, query *Query) (map[string]interface{}, error)
QueryTraits queries the traits of users based on the provided query. It takes a context.Context and a *Query as input parameters. It returns a map[string]interface{} containing the traits of the users and an error if any.
func (UserService) QueryUsers ¶
QueryUsers queries the user service with the given query and returns a list of users and an error, if any. The query parameter specifies the criteria for filtering the users. The returned list of users contains the user ID, username, UUID, attributes, and traits.
func (UserService) SearchEvents ¶
func (UserService) SearchUserTraits ¶
func (UserService) UpdateUser ¶
UpdateUser updates a user with the provided user data. It takes a context.Context and a pointer to a User struct as input. It returns a pointer to the updated User struct and an error if any.