From bff2b5e735ae7fc80157b4108ddbe56be8acb752 Mon Sep 17 00:00:00 2001 From: Chris Date: Mon, 9 Oct 2017 14:59:48 -0700 Subject: Miscellaneous app cleanup (#7594) * app cleanup * whoops, forgot a file * some minor cleanup * longer container deadline * defensive checks --- app/options.go | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 app/options.go (limited to 'app/options.go') 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") + } + } +} -- cgit v1.2.3-1-g7c22