-
Notifications
You must be signed in to change notification settings - Fork 405
/
nop.go
70 lines (57 loc) · 2.29 KB
/
nop.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
package hybrid
import (
"context"
"errors"
"io"
"github.com/fnproject/fn/api/agent"
"github.com/fnproject/fn/api/models"
"go.opencensus.io/trace"
)
// nopDataStore implements agent.DataAccess
type nopDataStore struct{}
func (cl *nopDataStore) GetTriggerBySource(ctx context.Context, appId string, triggerType, source string) (*models.Trigger, error) {
ctx, span := trace.StartSpan(ctx, "nop_datastore_get_trigger_by_source")
defer span.End()
return nil, errors.New("should not call GetTriggerBySource on a NOP data store")
}
func (cl *nopDataStore) GetFnByID(ctx context.Context, fnId string) (*models.Fn, error) {
ctx, span := trace.StartSpan(ctx, "nop_datastore_get_fn_by_id")
defer span.End()
return nil, errors.New("should not call GetFnByID on a NOP data store")
}
func NewNopDataStore() (agent.DataAccess, error) {
return &nopDataStore{}, nil
}
func (cl *nopDataStore) GetAppID(ctx context.Context, appName string) (string, error) {
ctx, span := trace.StartSpan(ctx, "nop_datastore_get_app_id")
defer span.End()
return "", errors.New("should not call GetAppID on a NOP data store")
}
func (cl *nopDataStore) GetAppByID(ctx context.Context, appID string) (*models.App, error) {
ctx, span := trace.StartSpan(ctx, "nop_datastore_get_app_by_id")
defer span.End()
return nil, errors.New("should not call GetAppByID on a NOP data store")
}
func (cl *nopDataStore) Enqueue(ctx context.Context, c *models.Call) error {
ctx, span := trace.StartSpan(ctx, "nop_datastore_enqueue")
defer span.End()
return errors.New("Should not call Enqueue on a NOP data store")
}
func (cl *nopDataStore) Dequeue(ctx context.Context) (*models.Call, error) {
ctx, span := trace.StartSpan(ctx, "nop_datastore_dequeue")
defer span.End()
return nil, errors.New("Should not call Dequeue on a NOP data store")
}
func (cl *nopDataStore) Start(ctx context.Context, c *models.Call) error {
ctx, span := trace.StartSpan(ctx, "nop_datastore_start")
defer span.End()
return nil // It's ok to call this method, and it does no operations
}
func (cl *nopDataStore) Finish(ctx context.Context, c *models.Call, r io.Reader, async bool) error {
ctx, span := trace.StartSpan(ctx, "nop_datastore_end")
defer span.End()
return nil // It's ok to call this method, and it does no operations
}
func (cl *nopDataStore) Close() error {
return nil
}