forked from ooni/probe-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tasksession.go
78 lines (61 loc) · 2.08 KB
/
tasksession.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 oonimkall
import (
"context"
"github.com/ooni/probe-cli/v3/internal/engine"
"github.com/ooni/probe-cli/v3/internal/kvstore"
"github.com/ooni/probe-cli/v3/internal/model"
)
//
// This file implements taskSession and derived types.
//
// taskKVStoreFSBuilderEngine creates a new KVStore
// using the ./internal/engine package.
type taskKVStoreFSBuilderEngine struct{}
var _ taskKVStoreFSBuilder = &taskKVStoreFSBuilderEngine{}
func (*taskKVStoreFSBuilderEngine) NewFS(path string) (model.KeyValueStore, error) {
return kvstore.NewFS(path)
}
// taskSessionBuilderEngine builds a new session
// using the ./internal/engine package.
type taskSessionBuilderEngine struct{}
var _ taskSessionBuilder = &taskSessionBuilderEngine{}
// NewSession implements taskSessionBuilder.NewSession.
func (b *taskSessionBuilderEngine) NewSession(ctx context.Context,
config engine.SessionConfig) (taskSession, error) {
sess, err := engine.NewSession(ctx, config)
if err != nil {
return nil, err
}
return &taskSessionEngine{sess}, nil
}
// taskSessionEngine wraps ./internal/engine's Session.
type taskSessionEngine struct {
*engine.Session
}
var _ taskSession = &taskSessionEngine{}
// NewExperimentBuilderByName implements
// taskSessionEngine.NewExperimentBuilderByName.
func (sess *taskSessionEngine) NewExperimentBuilderByName(
name string) (taskExperimentBuilder, error) {
builder, err := sess.NewExperimentBuilder(name)
if err != nil {
return nil, err
}
return &taskExperimentBuilderEngine{builder}, err
}
// taskExperimentBuilderEngine wraps ./internal/engine's
// ExperimentBuilder type.
type taskExperimentBuilderEngine struct {
model.ExperimentBuilder
}
var _ taskExperimentBuilder = &taskExperimentBuilderEngine{}
// NewExperimentInstance implements
// taskExperimentBuilder.NewExperimentInstance.
func (b *taskExperimentBuilderEngine) NewExperimentInstance() taskExperiment {
return &taskExperimentEngine{b.NewExperiment()}
}
// taskExperimentEngine wraps ./internal/engine's Experiment.
type taskExperimentEngine struct {
model.Experiment
}
var _ taskExperiment = &taskExperimentEngine{}