Skip to content

Commit 36a4e59

Browse files
add hostname in the initContext (#276)
Co-authored-by: Abhijit Wakchaure <[email protected]>
1 parent 009adc2 commit 36a4e59

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

Diff for: activity/activity.go

+9-7
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ import (
77

88
// Activity is an interface for defining a custom Activity Execution
99
type Activity interface {
10-
10+
1111
// Metadata returns the metadata of the activity
1212
Metadata() *Metadata
13-
13+
1414
// Eval is called when an Activity is being evaluated. Returning true indicates
1515
// that the task is done.
1616
Eval(ctx Context) (done bool, err error)
@@ -19,19 +19,21 @@ type Activity interface {
1919
type Factory func(ctx InitContext) (Activity, error)
2020

2121
type InitContext interface {
22-
22+
2323
// Settings
2424
Settings() map[string]interface{}
25-
25+
2626
// MapperFactory gets the mapper factory associated with the activity host
2727
MapperFactory() mapper.Factory
28-
28+
2929
// Logger logger to using during initialization, activity implementations should not
3030
// keep a reference to this
3131
Logger() log.Logger
32-
33-
// Name returns name of the activity
32+
33+
// Name returns name of the activity / task
3434
Name() string
35+
// HostName returns name of the flow / task host
36+
HostName() string
3537
}
3638

3739
type Details struct {

Diff for: api/support.go

+4
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,10 @@ func (ctx *initCtx) Name() string {
195195
return ""
196196
}
197197

198+
func (ctx *initCtx) HostName() string {
199+
return ""
200+
}
201+
198202
var activityLogger = log.ChildLogger(log.RootLogger(), "activity")
199203

200204
// EvalActivity evaluates the specified activity using the provided inputs

Diff for: support/test/context.go

+6
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ type TestActivityInitContext struct {
8888
settings map[string]interface{}
8989
factory mapper.Factory
9090
name string
91+
hostName string
9192
}
9293

9394
func (ic *TestActivityInitContext) Settings() map[string]interface{} {
@@ -101,10 +102,15 @@ func (ic *TestActivityInitContext) MapperFactory() mapper.Factory {
101102
func (ic *TestActivityInitContext) Logger() log.Logger {
102103
return logger
103104
}
105+
104106
func (ic *TestActivityInitContext) Name() string {
105107
return ic.name
106108
}
107109

110+
func (ic *TestActivityInitContext) HostName() string {
111+
return ic.hostName
112+
}
113+
108114
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
109115
// TestActivityHost
110116

0 commit comments

Comments
 (0)