/
pump.go
35 lines (29 loc) · 892 Bytes
/
pump.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Copyright 2020 Lingfei Kong <colin404@foxmail.com>. All rights reserved.
// Use of this source code is governed by a MIT style
// license that can be found in the LICENSE file.
package pumps
import (
"context"
"errors"
"github.com/marmotedu/iam/internal/pump/analytics"
)
// Pump defines the interface for all analytics back-end.
type Pump interface {
GetName() string
New() Pump
Init(interface{}) error
WriteData(context.Context, []interface{}) error
SetFilters(analytics.AnalyticsFilters)
GetFilters() analytics.AnalyticsFilters
SetTimeout(timeout int)
GetTimeout() int
SetOmitDetailedRecording(bool)
GetOmitDetailedRecording() bool
}
// GetPumpByName returns the pump instance by given name.
func GetPumpByName(name string) (Pump, error) {
if pump, ok := availablePumps[name]; ok && pump != nil {
return pump, nil
}
return nil, errors.New(name + " Not found")
}