Skip to content

Commit

Permalink
Fixed only one function executing from multiple choices (#13)
Browse files Browse the repository at this point in the history
Signed-off-by: Rishabh Gupta <r.g.gupta@outlook.com>
  • Loading branch information
zeerorg committed Jun 10, 2019
1 parent 4bfcf75 commit 14a1b7c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
21 changes: 21 additions & 0 deletions .vscode/launch.json
@@ -0,0 +1,21 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${fileDirname}",
"env": {
"basic_auth": "true",
"secret_mount_path": "${fileDirname}",
"gateway_url": "http://127.0.0.1:31112/"
},
"args": []
}
]
}
2 changes: 1 addition & 1 deletion main.go
Expand Up @@ -80,7 +80,7 @@ func startFunctionProbe(interval time.Duration, topic string, c *types.Controlle
newScheduledFuncs := make(cfunction.ScheduledFunctions, 0)

for _, function := range addFuncs {
f, err := cronScheduler.AddCronFunction(&function, invoker)
f, err := cronScheduler.AddCronFunction(function, invoker)
if err != nil {
log.Fatal("could not add function ", function.Name)
}
Expand Down
4 changes: 2 additions & 2 deletions types/scheduler.go
Expand Up @@ -33,12 +33,12 @@ type ScheduledFunction struct {
type ScheduledFunctions []ScheduledFunction

// AddCronFunction adds a function to cron
func (s *Scheduler) AddCronFunction(c *CronFunction, invoker *types.Invoker) (ScheduledFunction, error) {
func (s *Scheduler) AddCronFunction(c CronFunction, invoker *types.Invoker) (ScheduledFunction, error) {
eID, err := s.main.AddFunc(c.Schedule, func() {
log.Print(fmt.Sprint("Executed function: ", c.Name))
c.InvokeFunction(invoker)
})
return ScheduledFunction{*c, EntryID(eID)}, err
return ScheduledFunction{c, EntryID(eID)}, err
}

// NewScheduler returns a scheduler
Expand Down

0 comments on commit 14a1b7c

Please sign in to comment.