-
Notifications
You must be signed in to change notification settings - Fork 3.6k
/
Copy pathtelegraf_service.go
78 lines (68 loc) · 3.62 KB
/
telegraf_service.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package mock
import (
"context"
platform "github.com/influxdata/influxdb/v2"
)
var _ platform.TelegrafConfigStore = (*TelegrafConfigStore)(nil)
// TelegrafConfigStore represents a service for managing telegraf config data.
type TelegrafConfigStore struct {
*UserResourceMappingService
FindTelegrafConfigByIDF func(ctx context.Context, id platform.ID) (*platform.TelegrafConfig, error)
FindTelegrafConfigByIDCalls SafeCount
FindTelegrafConfigsF func(ctx context.Context, filter platform.TelegrafConfigFilter, opt ...platform.FindOptions) ([]*platform.TelegrafConfig, int, error)
FindTelegrafConfigsCalls SafeCount
CreateTelegrafConfigF func(ctx context.Context, tc *platform.TelegrafConfig, userID platform.ID) error
CreateTelegrafConfigCalls SafeCount
UpdateTelegrafConfigF func(ctx context.Context, id platform.ID, tc *platform.TelegrafConfig, userID platform.ID) (*platform.TelegrafConfig, error)
UpdateTelegrafConfigCalls SafeCount
DeleteTelegrafConfigF func(ctx context.Context, id platform.ID) error
DeleteTelegrafConfigCalls SafeCount
}
// NewTelegrafConfigStore constructs a new fake TelegrafConfigStore.
func NewTelegrafConfigStore() *TelegrafConfigStore {
return &TelegrafConfigStore{
UserResourceMappingService: NewUserResourceMappingService(),
FindTelegrafConfigByIDF: func(ctx context.Context, id platform.ID) (*platform.TelegrafConfig, error) {
return nil, nil
},
FindTelegrafConfigsF: func(_ context.Context, f platform.TelegrafConfigFilter, opt ...platform.FindOptions) ([]*platform.TelegrafConfig, int, error) {
return nil, 0, nil
},
CreateTelegrafConfigF: func(_ context.Context, tc *platform.TelegrafConfig, userID platform.ID) error {
return nil
},
UpdateTelegrafConfigF: func(_ context.Context, id platform.ID, tc *platform.TelegrafConfig, userID platform.ID) (*platform.TelegrafConfig, error) {
return nil, nil
},
DeleteTelegrafConfigF: func(_ context.Context, id platform.ID) error {
return nil
},
}
}
// FindTelegrafConfigByID returns a single telegraf config by ID.
func (s *TelegrafConfigStore) FindTelegrafConfigByID(ctx context.Context, id platform.ID) (*platform.TelegrafConfig, error) {
defer s.FindTelegrafConfigByIDCalls.IncrFn()()
return s.FindTelegrafConfigByIDF(ctx, id)
}
// FindTelegrafConfigs returns a list of telegraf configs that match filter and the total count of matching telegraf configs.
// Additional options provide pagination & sorting.
func (s *TelegrafConfigStore) FindTelegrafConfigs(ctx context.Context, filter platform.TelegrafConfigFilter, opt ...platform.FindOptions) ([]*platform.TelegrafConfig, int, error) {
defer s.FindTelegrafConfigsCalls.IncrFn()()
return s.FindTelegrafConfigsF(ctx, filter, opt...)
}
// CreateTelegrafConfig creates a new telegraf config and sets b.ID with the new identifier.
func (s *TelegrafConfigStore) CreateTelegrafConfig(ctx context.Context, tc *platform.TelegrafConfig, userID platform.ID) error {
defer s.CreateTelegrafConfigCalls.IncrFn()()
return s.CreateTelegrafConfigF(ctx, tc, userID)
}
// UpdateTelegrafConfig updates a single telegraf config.
// Returns the new telegraf config after update.
func (s *TelegrafConfigStore) UpdateTelegrafConfig(ctx context.Context, id platform.ID, tc *platform.TelegrafConfig, userID platform.ID) (*platform.TelegrafConfig, error) {
defer s.UpdateTelegrafConfigCalls.IncrFn()()
return s.UpdateTelegrafConfigF(ctx, id, tc, userID)
}
// DeleteTelegrafConfig removes a telegraf config by ID.
func (s *TelegrafConfigStore) DeleteTelegrafConfig(ctx context.Context, id platform.ID) error {
defer s.DeleteTelegrafConfigCalls.IncrFn()()
return s.DeleteTelegrafConfigF(ctx, id)
}