store

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("not found")

Functions

func GetKeyHash

func GetKeyHash(key string) string

GetKeyHash can be used to create a hash from a string

func GetOAuthKey

func GetOAuthKey(mattermostUserID string) string

func GetProjectKey

func GetProjectKey(projectID, mattermostUserID string) string

func GetProjectListMapKey

func GetProjectListMapKey() string

func GetSubscriptionKey added in v0.2.0

func GetSubscriptionKey(mattermostUserID, projectID, channelID, eventType string) string

func GetSubscriptionListMapKey added in v0.2.0

func GetSubscriptionListMapKey() string

func IsValidUserKey added in v0.2.1

func IsValidUserKey(key string) (string, bool)

Types

type KVStore added in v1.0.0

type KVStore interface {
	OAuthStore
	UserStore
	LinkStore
	SubscriptionStore
	DeleteUserTokenOnEncryptionSecretChange() error
}

func NewStore

func NewStore(api plugin.API) KVStore

type LinkStore added in v1.0.0

type LinkStore interface {
	StoreProject(project *serializers.ProjectDetails) error
	GetProject() (*ProjectList, error)
	GetAllProjects(userID string) ([]serializers.ProjectDetails, error)
	DeleteProject(project *serializers.ProjectDetails) error
}

type OAuthStore added in v1.0.0

type OAuthStore interface {
	StoreOAuthState(mattermostUserID, state string) error
	VerifyOAuthState(mattermostUserID, state string) error
}

type ProjectList

type ProjectList struct {
	ByMattermostUserID map[string]ProjectListMap
}

func NewProjectList

func NewProjectList() *ProjectList

func ProjectListFromJSON

func ProjectListFromJSON(bytes []byte) (*ProjectList, error)

func (*ProjectList) AddProject

func (projectList *ProjectList) AddProject(userID string, project *serializers.ProjectDetails)

func (*ProjectList) DeleteProjectByKey

func (projectList *ProjectList) DeleteProjectByKey(userID, projectKey string)

type ProjectListMap

type ProjectListMap map[string]serializers.ProjectDetails

type Store

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

func (*Store) AtomicModify

func (s *Store) AtomicModify(key string, modify func(initialValue []byte) ([]byte, error)) error

AtomicModify calls AtomicModifyWithOptions with nil PluginKVSetOptions to atomically modify a value in KVStore and set it for an indefinite time See AtomicModifyWithOptions for more info

func (*Store) AtomicModifyWithOptions

func (s *Store) AtomicModifyWithOptions(key string, modify func(initialValue []byte) ([]byte, *model.PluginKVSetOptions, error)) error

AtomicModifyWithOptions modifies the value for a key in KVStore, only if the initial value is not changed while attempting to modify it. To avoid race conditions, we retry the modification multiple times after waiting for a fixed wait interval. input: kv store key and a modify function which takes initial value and returns final value with PluginKVSetOptions and error. returns: nil for a successful update and error if the update is unsuccessful or the retry limit reached.

func (*Store) Delete

func (s *Store) Delete(key string) error

func (*Store) DeleteProject

func (s *Store) DeleteProject(project *serializers.ProjectDetails) error

func (*Store) DeleteSubscription added in v0.2.0

func (s *Store) DeleteSubscription(subscription *serializers.SubscriptionDetails) error

func (*Store) DeleteUser

func (s *Store) DeleteUser(mattermostUserID string) (bool, error)

func (*Store) DeleteUserTokenOnEncryptionSecretChange added in v1.0.0

func (s *Store) DeleteUserTokenOnEncryptionSecretChange() error

func (*Store) Ensure

func (s *Store) Ensure(key string, newValue []byte) ([]byte, error)

Ensure makes sure the initial value for a key is set to the value provided, if it does not already exist Returns the value set for the key in kv-store and error

func (*Store) GetAllProjects

func (s *Store) GetAllProjects(userID string) ([]serializers.ProjectDetails, error)

func (*Store) GetAllSubscriptions added in v0.2.0

func (s *Store) GetAllSubscriptions(userID string) ([]*serializers.SubscriptionDetails, error)

func (*Store) GetProject

func (s *Store) GetProject() (*ProjectList, error)

func (*Store) GetSubscriptionList added in v1.0.0

func (s *Store) GetSubscriptionList() (*SubscriptionList, error)

func (*Store) Load

func (s *Store) Load(key string) ([]byte, error)

func (*Store) LoadJSON

func (s *Store) LoadJSON(key string, v interface{}) (returnErr error)

LoadJSON loads a json value stored in the KVStore using StoreJSON unmarshalling it to an interface using json.Unmarshal

func (*Store) LoadUser

func (s *Store) LoadUser(mattermostUserID string) (*serializers.User, error)

func (*Store) Store

func (s *Store) Store(key string, data []byte) error

func (*Store) StoreJSON

func (s *Store) StoreJSON(key string, v interface{}) (returnErr error)

StoreJSON stores a json value from an interface to KVStore after marshaling it using json.Marshal

func (*Store) StoreOAuthState

func (s *Store) StoreOAuthState(mattermostUserID, state string) error

func (*Store) StoreProject

func (s *Store) StoreProject(project *serializers.ProjectDetails) error

func (*Store) StoreSubscription added in v0.2.0

func (s *Store) StoreSubscription(subscription *serializers.SubscriptionDetails) error

func (*Store) StoreTTL

func (s *Store) StoreTTL(key string, data []byte, ttlSeconds int64) error

func (*Store) StoreUser

func (s *Store) StoreUser(user *serializers.User) error

func (*Store) StoreWithOptions

func (s *Store) StoreWithOptions(key string, value []byte, opts model.PluginKVSetOptions) (bool, error)

func (*Store) VerifyOAuthState

func (s *Store) VerifyOAuthState(mattermostUserID, state string) error

type SubscriptionList added in v0.2.0

type SubscriptionList struct {
	ByMattermostUserID map[string]SubscriptionListMap
}

func NewSubscriptionList added in v0.2.0

func NewSubscriptionList() *SubscriptionList

func SubscriptionListFromJSON added in v0.2.0

func SubscriptionListFromJSON(bytes []byte) (*SubscriptionList, error)

func (*SubscriptionList) AddSubscription added in v0.2.0

func (subscriptionList *SubscriptionList) AddSubscription(userID string, subscription *serializers.SubscriptionDetails)

func (*SubscriptionList) DeleteSubscriptionByKey added in v0.2.0

func (subscriptionList *SubscriptionList) DeleteSubscriptionByKey(userID, subscriptionKey string)

type SubscriptionListMap added in v0.2.0

type SubscriptionListMap map[string]serializers.SubscriptionDetails

type SubscriptionStore added in v1.0.0

type SubscriptionStore interface {
	StoreSubscription(subscription *serializers.SubscriptionDetails) error
	GetSubscriptionList() (*SubscriptionList, error)
	GetAllSubscriptions(userID string) ([]*serializers.SubscriptionDetails, error)
	DeleteSubscription(subscription *serializers.SubscriptionDetails) error
}

type UserStore added in v1.0.0

type UserStore interface {
	LoadUser(mattermostUserID string) (*serializers.User, error)
	StoreUser(user *serializers.User) error
	DeleteUser(mattermostUserID string) (bool, error)
}

Jump to

Keyboard shortcuts

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