Skip to content

Commit a11de63

Browse files
committed
added helper functions for programmatic use
1 parent 9d15fc4 commit a11de63

File tree

2 files changed

+47
-9
lines changed

2 files changed

+47
-9
lines changed

pkg/coordinator/scheduler/options.go

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ type TaskOptsSettings struct {
2727
Timeout human.Duration `yaml:"timeout" json:"timeout"`
2828
}
2929

30-
func (ts *TaskScheduler) NewTaskOptions(task *types.TaskDescriptor, config interface{}, settings *TaskOptsSettings) (*types.TaskOptions, error) {
30+
func (ts *TaskScheduler) NewTaskOptions(task string, config interface{}, settings *TaskOptsSettings) *types.TaskOptions {
3131
options := &types.TaskOptions{
32-
Name: task.Name,
32+
Name: task,
3333
}
3434

3535
if settings != nil {
@@ -41,14 +41,18 @@ func (ts *TaskScheduler) NewTaskOptions(task *types.TaskDescriptor, config inter
4141
if config != nil {
4242
configYaml, err := yaml.Marshal(config)
4343
if err != nil {
44-
return nil, fmt.Errorf("error serializing task config: %w", err)
45-
}
46-
47-
err = yaml.Unmarshal(configYaml, options.Config)
48-
if err != nil {
49-
return nil, fmt.Errorf("error parsing task config: %w", err)
44+
ts.logger.Errorf("failed marshalling task options: %v", err)
45+
} else {
46+
configRaw := helper.RawMessage{}
47+
48+
err = yaml.Unmarshal(configYaml, &configRaw)
49+
if err != nil {
50+
ts.logger.Errorf("failed unmarshalling task options: %v", err)
51+
} else {
52+
options.Config = &configRaw
53+
}
5054
}
5155
}
5256

53-
return options, nil
57+
return options
5458
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package scheduler
2+
3+
import (
4+
"github.com/ethpandaops/assertoor/pkg/coordinator/clients"
5+
"github.com/ethpandaops/assertoor/pkg/coordinator/names"
6+
"github.com/ethpandaops/assertoor/pkg/coordinator/types"
7+
"github.com/ethpandaops/assertoor/pkg/coordinator/wallet"
8+
)
9+
10+
type servicesProvider struct {
11+
clientPool *clients.ClientPool
12+
walletManager *wallet.Manager
13+
validatorNames *names.ValidatorNames
14+
}
15+
16+
func NewServicesProvider(clientPool *clients.ClientPool, walletManager *wallet.Manager, validatorNames *names.ValidatorNames) types.TaskServices {
17+
return &servicesProvider{
18+
clientPool: clientPool,
19+
walletManager: walletManager,
20+
validatorNames: validatorNames,
21+
}
22+
}
23+
24+
func (p *servicesProvider) ClientPool() *clients.ClientPool {
25+
return p.clientPool
26+
}
27+
28+
func (p *servicesProvider) WalletManager() *wallet.Manager {
29+
return p.walletManager
30+
}
31+
32+
func (p *servicesProvider) ValidatorNames() *names.ValidatorNames {
33+
return p.validatorNames
34+
}

0 commit comments

Comments
 (0)