Documentation ¶
Index ¶
- Variables
- func SetRandomSeed() int64
- type CQueue
- type Config
- type MemStore
- func (s *MemStore) Channel(channelId string) (*model.Channel, error)
- func (s *MemStore) ChannelMember(channelId, userId string) (model.ChannelMember, error)
- func (s *MemStore) ChannelMembers(channelId string) (*model.ChannelMembers, error)
- func (s *MemStore) ChannelPosts(channelId string) ([]*model.Post, error)
- func (s *MemStore) ChannelPostsSorted(channelId string, asc bool) ([]*model.Post, error)
- func (s *MemStore) ChannelStats(channelId string) (*model.ChannelStats, error)
- func (s *MemStore) ChannelView(channelId string) (int64, error)
- func (s *MemStore) Channels(teamId string) ([]model.Channel, error)
- func (s *MemStore) Clear()
- func (s *MemStore) ClientConfig() map[string]string
- func (s *MemStore) Config() model.Config
- func (s *MemStore) CurrentChannel() (*model.Channel, error)
- func (s *MemStore) CurrentTeam() (*model.Team, error)
- func (s *MemStore) DeletePost(postId string) error
- func (s *MemStore) DeleteReaction(reaction *model.Reaction) (bool, error)
- func (s *MemStore) Email() string
- func (s *MemStore) FileInfoForPost(postId string) ([]*model.FileInfo, error)
- func (s *MemStore) GetUser(userId string) (model.User, error)
- func (s *MemStore) Id() string
- func (s *MemStore) Password() string
- func (s *MemStore) Post(postId string) (*model.Post, error)
- func (s *MemStore) PostsIdsSince(ts int64) ([]string, error)
- func (s *MemStore) Preferences() (model.Preferences, error)
- func (s *MemStore) ProfileImage(userId string) (bool, error)
- func (s *MemStore) RandomChannel(teamId string, st store.SelectionType) (model.Channel, error)
- func (s *MemStore) RandomChannelMember(channelId string) (model.ChannelMember, error)
- func (s *MemStore) RandomEmoji() (model.Emoji, error)
- func (s *MemStore) RandomPost() (model.Post, error)
- func (s *MemStore) RandomPostForChannel(channelId string) (model.Post, error)
- func (s *MemStore) RandomPostForChannelByUser(channelId, userId string) (model.Post, error)
- func (s *MemStore) RandomTeam(st store.SelectionType) (model.Team, error)
- func (s *MemStore) RandomTeamMember(teamId string) (model.TeamMember, error)
- func (s *MemStore) RandomUser() (model.User, error)
- func (s *MemStore) RandomUsers(n int) ([]model.User, error)
- func (s *MemStore) Reactions(postId string) ([]model.Reaction, error)
- func (s *MemStore) RemoveChannelMember(channelId string, userId string) error
- func (s *MemStore) RemoveTeamMember(teamId string, userId string) error
- func (s *MemStore) Roles() ([]model.Role, error)
- func (s *MemStore) ServerVersion() (string, error)
- func (s *MemStore) SetChannel(channel *model.Channel) error
- func (s *MemStore) SetChannelMember(channelId string, channelMember *model.ChannelMember) error
- func (s *MemStore) SetChannelMembers(channelMembers *model.ChannelMembers) error
- func (s *MemStore) SetChannelStats(channelId string, stats *model.ChannelStats) error
- func (s *MemStore) SetChannelView(channelId string) error
- func (s *MemStore) SetChannels(channels []*model.Channel) error
- func (s *MemStore) SetClientConfig(config map[string]string)
- func (s *MemStore) SetConfig(config *model.Config)
- func (s *MemStore) SetCurrentChannel(channel *model.Channel) error
- func (s *MemStore) SetCurrentTeam(team *model.Team) error
- func (s *MemStore) SetEmojis(emoji []*model.Emoji) error
- func (s *MemStore) SetLicense(license map[string]string) error
- func (s *MemStore) SetPost(post *model.Post) error
- func (s *MemStore) SetPosts(posts []*model.Post) error
- func (s *MemStore) SetPreferences(preferences *model.Preferences) error
- func (s *MemStore) SetProfileImage(userId string) error
- func (s *MemStore) SetReaction(reaction *model.Reaction) error
- func (s *MemStore) SetReactions(postId string, reactions []*model.Reaction) error
- func (s *MemStore) SetRoles(roles []*model.Role) error
- func (s *MemStore) SetServerVersion(version string) error
- func (s *MemStore) SetStatus(userId string, status *model.Status) error
- func (s *MemStore) SetTeam(team *model.Team) error
- func (s *MemStore) SetTeamMember(teamId string, teamMember *model.TeamMember) error
- func (s *MemStore) SetTeamMembers(teamId string, teamMembers []*model.TeamMember) error
- func (s *MemStore) SetTeams(teams []*model.Team) error
- func (s *MemStore) SetUser(user *model.User) error
- func (s *MemStore) SetUsers(users []*model.User) error
- func (s *MemStore) Status(userId string) (model.Status, error)
- func (s *MemStore) Team(teamId string) (*model.Team, error)
- func (s *MemStore) TeamMember(teamId, userId string) (model.TeamMember, error)
- func (s *MemStore) Teams() ([]model.Team, error)
- func (s *MemStore) User() (*model.User, error)
- func (s *MemStore) UserForPost(postId string) (string, error)
- func (s *MemStore) Username() string
- func (s *MemStore) UsersIdsForPostsIds(postIds []string) ([]string, error)
Constants ¶
This section is empty.
Variables ¶
var ( ErrEmptyMap = errors.New("memstore: cannot select from an empty map") ErrEmptySlice = errors.New("memstore: cannot select from an empty slice") ErrLenMismatch = errors.New("memstore: cannot select from a map, not enough elements") ErrTeamNotFound = errors.New("memstore: team not found") ErrUserNotSet = errors.New("memstore: user is not set") ErrTeamStoreEmpty = errors.New("memstore: team store is empty") ErrChannelStoreEmpty = errors.New("memstore: channel store is empty") ErrChannelNotFound = errors.New("memstore: channel not found") ErrPostNotFound = errors.New("memstore: post not found") ErrInvalidData = errors.New("memstore: invalid data found") )
Functions ¶
func SetRandomSeed ¶
func SetRandomSeed() int64
SetRandomSeed sets the global random seed and returns it's value.
Types ¶
type CQueue ¶
type CQueue struct {
// contains filtered or unexported fields
}
CQueue is a basic implementation of a circular queue of fixed size.
func NewCQueue ¶
NewCQueue creates and returns a pointer to a queue of the given size. The passed newEl parameter is a function used to allocate an element if data for it is not yet present in the queue.
type Config ¶
type Config struct { MaxStoredPosts int // The maximum number of posts to be stored. MaxStoredUsers int // The maximum number of users to be stored. MaxStoredChannelMembers int // The maximum number of channel members to be stored. MaxStoredStatuses int // The maximum number of statuses to be stored. }
Config holds information used to create a new MemStore.
func (*Config) IsValid ¶
IsValid checks whether a Config is valid or not. Returns an error if the validation fails.
func (*Config) SetDefaults ¶
func (c *Config) SetDefaults()
SetDefaults sets default values to the config.
type MemStore ¶
type MemStore struct {
// contains filtered or unexported fields
}
MemStore is a simple implementation of MutableUserStore which holds all data in memory.
func New ¶
New returns a new instance of MemStore with the given config. If config is nil, defaults will be used.
func (*MemStore) ChannelMember ¶
func (s *MemStore) ChannelMember(channelId, userId string) (model.ChannelMember, error)
ChannelMember returns the channel member for the given channelId and userId.
func (*MemStore) ChannelMembers ¶
func (s *MemStore) ChannelMembers(channelId string) (*model.ChannelMembers, error)
ChannelMembers returns a list of members for the specified channel.
func (*MemStore) ChannelPosts ¶
ChannelPosts returns all posts for the specified channel.
func (*MemStore) ChannelPostsSorted ¶
ChannelPostsSorted returns all posts for specified channel, sorted by CreateAt.
func (*MemStore) ChannelStats ¶ added in v1.3.0
func (s *MemStore) ChannelStats(channelId string) (*model.ChannelStats, error)
ChannelStats returns statistics for the given channelId.
func (*MemStore) ChannelView ¶
ChannelView returns the timestamp of the last view for the given channelId.
func (*MemStore) Clear ¶
func (s *MemStore) Clear()
Clear resets the store and removes all entries with the exception of the user object and state information (current team/channel) which are preserved.
func (*MemStore) ClientConfig ¶ added in v1.3.0
ClientConfig returns the limited server configuration settings for user.
func (*MemStore) CurrentChannel ¶
GetCurrentChannel returns the channel the user is currently viewing.
func (*MemStore) CurrentTeam ¶
GetCurrentTeam returns the currently selected team for the user.
func (*MemStore) DeletePost ¶
DeletePost deletes the specified post.
func (*MemStore) DeleteReaction ¶
DeleteReaction deletes the given reaction. It returns whether or not the reaction was deleted.
func (*MemStore) FileInfoForPost ¶
FileInfoForPost returns the FileInfo for the specified post, if any.
func (*MemStore) PostsIdsSince ¶
PostsIdsSince returns a list of post ids for posts created after a specified timestamp in milliseconds.
func (*MemStore) Preferences ¶
func (s *MemStore) Preferences() (model.Preferences, error)
Preferences returns the preferences for the stored user.
func (*MemStore) ProfileImage ¶
ProfileImage returns whether the profile image for the given user has been stored.
func (*MemStore) RandomChannel ¶
RandomChannel returns a random channel for the given teamId for the current user.
func (*MemStore) RandomChannelMember ¶
func (s *MemStore) RandomChannelMember(channelId string) (model.ChannelMember, error)
RandomChannelMember returns a random channel member for a channel.
func (*MemStore) RandomEmoji ¶
RandomEmoji returns a random emoji.
func (*MemStore) RandomPost ¶
RandomPost returns a random post.
func (*MemStore) RandomPostForChannel ¶
RandomPostForChannel returns a random post for the given channel.
func (*MemStore) RandomPostForChannelByUser ¶
RandomPostForChannelForUser returns a random post for the given channel made by the given user.
func (*MemStore) RandomTeam ¶
RandomTeam returns a random team for the current user.
func (*MemStore) RandomTeamMember ¶
func (s *MemStore) RandomTeamMember(teamId string) (model.TeamMember, error)
RandomTeamMember returns a random team member for a team.
func (*MemStore) RandomUser ¶
RandomUser returns a random user from the set of users.
func (*MemStore) RandomUsers ¶
RandomUsers returns N random users from the set of users.
func (*MemStore) RemoveChannelMember ¶
RemoveChannelMember removes the channel member for the specified channel and user.
func (*MemStore) RemoveTeamMember ¶
RemoveTeamMember removes the team member for the specified team and user..
func (*MemStore) ServerVersion ¶ added in v1.2.0
ServerVersion returns the server version string.
func (*MemStore) SetChannel ¶
SetChannel stores the given channel.
func (*MemStore) SetChannelMember ¶
func (s *MemStore) SetChannelMember(channelId string, channelMember *model.ChannelMember) error
SetChannelMember stores the given channel member.
func (*MemStore) SetChannelMembers ¶
func (s *MemStore) SetChannelMembers(channelMembers *model.ChannelMembers) error
SetChannelMembers stores the given channel members in the store.
func (*MemStore) SetChannelStats ¶ added in v1.3.0
func (s *MemStore) SetChannelStats(channelId string, stats *model.ChannelStats) error
SetChannelStats stores statistics for the given channelId.
func (*MemStore) SetChannelView ¶
SetChannelView marks the given channel as viewed and updates the store with the current timestamp.
func (*MemStore) SetChannels ¶
SetChannels adds the given channels to the store.
func (*MemStore) SetClientConfig ¶ added in v1.3.0
Set ClientConfig stores the given limited configuration settings.
func (*MemStore) SetCurrentChannel ¶
SetCurrentChannel stores the channel the user is currently viewing.
func (*MemStore) SetCurrentTeam ¶
SetCurrentTeam sets the currently selected team for the user.
func (*MemStore) SetLicense ¶
SetLicense stores the given license in the store.
func (*MemStore) SetPreferences ¶
func (s *MemStore) SetPreferences(preferences *model.Preferences) error
Preferences stores the preferences for the stored user.
func (*MemStore) SetProfileImage ¶
SetProfileImage sets as stored the profile image for the given user.
func (*MemStore) SetReaction ¶
SetReaction stores the given reaction.
func (*MemStore) SetReactions ¶
SetReactions stores the given reactions for the specified post.
func (*MemStore) SetServerVersion ¶ added in v1.2.0
SetProfileImage sets as stored the profile image for the given user.
func (*MemStore) SetTeamMember ¶
func (s *MemStore) SetTeamMember(teamId string, teamMember *model.TeamMember) error
SetTeamMember stores the given team member.
func (*MemStore) SetTeamMembers ¶
func (s *MemStore) SetTeamMembers(teamId string, teamMembers []*model.TeamMember) error
SetTeamMembers stores the given team members.
func (*MemStore) TeamMember ¶
func (s *MemStore) TeamMember(teamId, userId string) (model.TeamMember, error)
TeamMember returns the team member for the given teamId and userId.
func (*MemStore) UserForPost ¶
UserForPost returns the userId for the user who created the specified post.