summaryrefslogtreecommitdiffstats
path: root/app/options.go
diff options
context:
space:
mode:
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")
+ }
+ }
+}