store

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2022 License: Apache-2.0 Imports: 11 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

Types

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 NewStore

func NewStore(api plugin.API) *Store

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) DeleteUser

func (s *Store) DeleteUser(mattermostUserID string) (bool, 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) GetProject

func (s *Store) GetProject() (*ProjectList, 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) (*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) StoreTTL

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

func (*Store) StoreUser

func (s *Store) StoreUser(user *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 User

type User struct {
	MattermostUserID string
	AccessToken      string
	RefreshToken     string
	ExpiresIn        string
}

Jump to

Keyboard shortcuts

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