summaryrefslogtreecommitdiffstats
path: root/app/options.go
diff options
context:
space:
mode:
authorChris <ccbrown112@gmail.com>2017-10-09 14:59:48 -0700
committerGitHub <noreply@github.com>2017-10-09 14:59:48 -0700
commitbff2b5e735ae7fc80157b4108ddbe56be8acb752 (patch)
tree14867d2bff71b6b638b0b358b1f38eb062cb597f /app/options.go
parent0f66b6e72621842467d0e368b95ee58f485d4ace (diff)
downloadchat-bff2b5e735ae7fc80157b4108ddbe56be8acb752.tar.gz
chat-bff2b5e735ae7fc80157b4108ddbe56be8acb752.tar.bz2
chat-bff2b5e735ae7fc80157b4108ddbe56be8acb752.zip
Miscellaneous app cleanup (#7594)
* app cleanup * whoops, forgot a file * some minor cleanup * longer container deadline * defensive checks
Diffstat (limited to 'app/options.go')
-rw-r--r--app/options.go29
1 files changed, 29 insertions, 0 deletions
diff --git a/app/options.go b/app/options.go
new file mode 100644
index 000000000..3058769d6
--- /dev/null
+++ b/app/options.go
@@ -0,0 +1,29 @@
+// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
+// See License.txt for license information.
+
+package app
+
+import (
+ "github.com/mattermost/mattermost-server/store"
+)
+
+type Option func(a *App)
+
+// By default, the app will use the store specified by the configuration. This allows you to
+// construct an app with a different store.
+//
+// The storeOrFactory parameter must be either a store.Store or func() store.Store.
+func StoreOverride(storeOrFactory interface{}) Option {
+ return func(a *App) {
+ switch s := storeOrFactory.(type) {
+ case store.Store:
+ a.newStore = func() store.Store {
+ return s
+ }
+ case func() store.Store:
+ a.newStore = s
+ default:
+ panic("invalid StoreOverride")
+ }
+ }
+}