Skip to content

Commit

Permalink
add hostname in the initContext (#276)
Browse files Browse the repository at this point in the history
Co-authored-by: Abhijit Wakchaure <[email protected]>
  • Loading branch information
awakchau-tibco and abhijitWakchaure authored Mar 3, 2023
1 parent 009adc2 commit 36a4e59
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
16 changes: 9 additions & 7 deletions activity/activity.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import (

// Activity is an interface for defining a custom Activity Execution
type Activity interface {

// Metadata returns the metadata of the activity
Metadata() *Metadata

// Eval is called when an Activity is being evaluated. Returning true indicates
// that the task is done.
Eval(ctx Context) (done bool, err error)
Expand All @@ -19,19 +19,21 @@ type Activity interface {
type Factory func(ctx InitContext) (Activity, error)

type InitContext interface {

// Settings
Settings() map[string]interface{}

// MapperFactory gets the mapper factory associated with the activity host
MapperFactory() mapper.Factory

// Logger logger to using during initialization, activity implementations should not
// keep a reference to this
Logger() log.Logger
// Name returns name of the activity

// Name returns name of the activity / task
Name() string
// HostName returns name of the flow / task host
HostName() string
}

type Details struct {
Expand Down
4 changes: 4 additions & 0 deletions api/support.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,10 @@ func (ctx *initCtx) Name() string {
return ""
}

func (ctx *initCtx) HostName() string {
return ""
}

var activityLogger = log.ChildLogger(log.RootLogger(), "activity")

// EvalActivity evaluates the specified activity using the provided inputs
Expand Down
6 changes: 6 additions & 0 deletions support/test/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ type TestActivityInitContext struct {
settings map[string]interface{}
factory mapper.Factory
name string
hostName string
}

func (ic *TestActivityInitContext) Settings() map[string]interface{} {
Expand All @@ -101,10 +102,15 @@ func (ic *TestActivityInitContext) MapperFactory() mapper.Factory {
func (ic *TestActivityInitContext) Logger() log.Logger {
return logger
}

func (ic *TestActivityInitContext) Name() string {
return ic.name
}

func (ic *TestActivityInitContext) HostName() string {
return ic.hostName
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// TestActivityHost

Expand Down

0 comments on commit 36a4e59

Please sign in to comment.