Skip to content

A task execution service written in golang that consumes a RabbitMQ queue and queue and executes tasks in parallel

Notifications You must be signed in to change notification settings

Nabeegh-Ahmed/task-execution-service

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Task Execution Service

A task execution service written in Golang. It consumes a RabbitMQ queue and executes tasks inside a worker. The service provides an easy to use interface to pass function pointers and arguments for tasks to be executed inside the service.

Get Started

  • Clone the repo
  • Add your tasks in tasklets
  • Add a wrapper for your tasklet that takes in arbitrary arguments. Use the following template as example
    func SomeFuncWrapper(args ...interface{}) (interface{}, error) {
      if len(args) != 1 {
      	return nil, fmt.Errorf("SomeFunc expects 1 arguments")
      }
    // Check for types
      a, ok1 := args[0].(int32)
      if !ok1 {
      	return nil, fmt.Errorf("invalid argument types for SomeFunc")
      }
    // Execute the main function
      return someFunc(a), nil
  • Run go generate
  • Now you can enqueue this task as you please by using
    execution := taskExecution.TaskExecutionInit()
      execution.Enqueue(tasklets.IsPrime, 5)
  • You can spawn more workers to execute tasks using go worker.Worker()

About

A task execution service written in golang that consumes a RabbitMQ queue and queue and executes tasks in parallel

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages