Skip to content

Commit

Permalink
CallFunction changes and new fields to Event interface (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
omesser authored May 10, 2020
1 parent c5d7db4 commit 85f6643
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
20 changes: 18 additions & 2 deletions event.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,15 @@ type Event interface {

// GetVersion returns the version of the event
GetVersion() string

// GetLastInBatch returns whether the event is the last event in a trigger specific batch
GetLastInBatch() bool

// GetOffset returns the offset of the event
GetOffset() int
}

// AbstractEvent provides a base implemention of an event
// AbstractEvent provides a base implementation of an event
type AbstractEvent struct {
triggerInfoProvider TriggerInfoProvider
id ID
Expand All @@ -137,7 +143,7 @@ func (ae *AbstractEvent) SetTriggerInfoProvider(triggerInfoProvider TriggerInfoP
ae.triggerInfoProvider = triggerInfoProvider
}

// GetTriggerInfo retruns a trigger info provider
// GetTriggerInfo returns a trigger info provider
func (ae *AbstractEvent) GetTriggerInfo() TriggerInfoProvider {
return ae.triggerInfoProvider
}
Expand Down Expand Up @@ -276,3 +282,13 @@ func (ae *AbstractEvent) GetTypeVersion() string {
func (ae *AbstractEvent) GetVersion() string {
return ""
}

// GetLastInBatch returns whether the event is the last event in a trigger specific batch
func (ae *AbstractEvent) GetLastInBatch() bool {
return false
}

// GetOffset returns the offset of the event
func (ae *AbstractEvent) GetOffset() int {
return 0
}
3 changes: 1 addition & 2 deletions memoryevent.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ func (me *MemoryEvent) GetMethod() string {
if me.Method == "" {
if len(me.Body) == 0 {
return "GET"
} else {
return "POST"
}
return "POST"
}
return me.Method
}
Expand Down
9 changes: 7 additions & 2 deletions platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,15 @@ func (p *Platform) CallFunction(functionName string, event Event) (Response, err
}

func (p *Platform) getFunctionHost(name string) string {
var functionHost string

if p.kind == "local" {
return fmt.Sprintf("%s-%s:8080", p.namespace, name)
functionHost = fmt.Sprintf("nuclio-%s-%s", p.namespace, name)
} else {
functionHost = fmt.Sprintf("nuclio-%s", name)
}
return fmt.Sprintf("%s:8080", name)

return fmt.Sprintf("%s:8080", functionHost)
}

func (p *Platform) createRequest(functionName string, event Event) *fasthttp.Request {
Expand Down

0 comments on commit 85f6643

Please sign in to comment.