package main

import (
	"fmt"

	worker "github.com/contribsys/faktory_worker_go"
	keycloak "github.com/kindlyops/mappamundi/havenapi/keycloak"
)

// CreateUser creates a new user with keycloak
func CreateUser(ctx worker.Context, args ...interface{}) error {
	fmt.Println("Working on job", ctx.Jid())
	err := keycloak.KeycloakCreateUser(args[0].(string))
	if err != nil {
		return ctx.Err()
	}
	return err
}

func main() {
	mgr := worker.NewManager()

	// register job types and the function to execute them
	mgr.Register("CreateUser", CreateUser)
	//mgr.Register("AnotherJob", anotherFunc)

	// use up to N goroutines to execute jobs
	mgr.Concurrency = 20

	// pull jobs from these queues, in this order of precedence
	mgr.Queues = []string{"critical", "default", "bulk"}

	// Start processing jobs, this method does not return
	mgr.Run()
}

package main

import (
	"fmt"

	worker "github.com/contribsys/faktory_worker_go"
	keycloak "github.com/kindlyops/mappamundi/havenapi/keycloak"
)

// CreateUser creates a new user with keycloak
func CreateUser(ctx worker.Context, args ...interface{}) error {
	fmt.Println("Working on job", ctx.Jid())
	err := keycloak.KeycloakCreateUser(args[0])
	if err != nil {
		return ctx.Error(500, err)
	}
	return err
}

func main() {
	mgr := worker.NewManager()

	// register job types and the function to execute them
	mgr.Register("CreateUser", CreateUser)
	//mgr.Register("AnotherJob", anotherFunc)

	// use up to N goroutines to execute jobs
	mgr.Concurrency = 20

	// pull jobs from these queues, in this order of precedence
	mgr.Queues = []string{"critical", "default", "bulk"}

	// Start processing jobs, this method does not return
	mgr.Run()
}

--- 
+++ 
@@ -10,9 +10,9 @@
 // CreateUser creates a new user with keycloak
 func CreateUser(ctx worker.Context, args ...interface{}) error {
 	fmt.Println("Working on job", ctx.Jid())
-	err := keycloak.KeycloakCreateUser(args[0])
+	err := keycloak.KeycloakCreateUser(args[0].(string))
 	if err != nil {
-		return ctx.Error(500, err)
+		return ctx.Err()
 	}
 	return err
 }
Refactor to properly pull arg as a string.

Issue #HAV-133

Signed-off-by: Christopher Mundus <711c73f64afdce07b7e38039a96d2224209e9a6c@kindlyops.com>
