-
Notifications
You must be signed in to change notification settings - Fork 23
/
experiment_engine.go
43 lines (36 loc) · 1.31 KB
/
experiment_engine.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
package models
import (
"database/sql/driver"
"encoding/json"
"errors"
"github.com/caraml-dev/turing/api/turing/config"
)
const (
ExperimentEngineTypeNop string = "nop"
)
// ExperimentEngine contains the type and configuration for the
// Experiment engine powering the router.
type ExperimentEngine struct {
// Type of Experiment Engine
Type string `json:"type"`
// PluginConfig (Optional) contains necessary configuration, if experiment engine
// is implemented as RPC plugin
PluginConfig *config.ExperimentEnginePluginConfig `json:"plugin_config,omitempty"`
// ServiceAccount contains the service account file path that points to the service account
// key that the experiment engine may require
ServiceAccountKeyFilePath *string `json:"service_account_key_file_path,omitempty"`
// Config contains the configs for the selected experiment engine (other than "nop").
// For standard experiment engine managers, the config can be unmarshalled into
// manager.TuringExperimentConfig type.
Config json.RawMessage `json:"config,omitempty"`
}
func (eec ExperimentEngine) Value() (driver.Value, error) {
return json.Marshal(eec)
}
func (eec *ExperimentEngine) Scan(value interface{}) error {
b, ok := value.([]byte)
if !ok {
return errors.New("type assertion to []byte failed")
}
return json.Unmarshal(b, &eec)
}