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()
}

package main

import (
	"fmt"
	worker "github.com/contribsys/faktory_worker_go"
)

func someFunc(ctx worker.Context, args ...interface{}) error {
	fmt.Println("Working on job", ctx.Jid())
	return nil
}

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

	// register job types and the function to execute them
	mgr.Register("SomeJob", someFunc)
	//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()
}

--- 
+++ 
@@ -2,19 +2,26 @@
 
 import (
 	"fmt"
+
 	worker "github.com/contribsys/faktory_worker_go"
+	keycloak "github.com/kindlyops/mappamundi/havenapi/keycloak"
 )
 
-func someFunc(ctx worker.Context, args ...interface{}) error {
+// CreateUser creates a new user with keycloak
+func CreateUser(ctx worker.Context, args ...interface{}) error {
 	fmt.Println("Working on job", ctx.Jid())
-	return nil
+	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("SomeJob", someFunc)
+	mgr.Register("CreateUser", CreateUser)
 	//mgr.Register("AnotherJob", anotherFunc)
 
 	// use up to N goroutines to execute jobs
Refactor to use new keycloak package.

Issue #HAV-133

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