gearmin

package module
v0.0.0-...-e15b2db Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 7, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

README

gearmin

go.dev reference

A lightweight, embeddable implementation of the Gearman job server protocol, written in Go. It is designed for developers looking for an in-process job server compatible with existing Gearman workers. Unlike gearmand, job submissions are facilitated through direct API access.

Please do not use this implementation yet as it has not undergone testing.

Usage

srv := gearmin.NewServerWithAddr(":4730")
defer srv.Stop()

srv.Submit(&gearmin.JobRequest{
  FuncName:   "sum",
  Data:       []byte(`{"x":1,"y":2}`),
  Background: false,
  Callback: func(update JobUpdate) {
    fmt.Println("Done!")
  },
})

Acknowledgement

License

Apache 2.0. See LICENSE.

  • Copyright (C) by AppsCode Inc.
  • Copyright (C) by @ngaut

Documentation

Overview

nolint: unused

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JobRequest

type JobRequest struct {
	FuncName   string            // Function name.
	ID         string            // Job identifier.
	Data       []byte            // Job data payload.
	Background bool              // Whether this is a background job.
	Callback   JobUpdateCallback // Only used by non-background jobs.
}

type JobUpdate

type JobUpdate struct {
	Type   JobUpdateType
	Handle string
	Status [2]int // Status numerator and denominator.
	Data   []byte // Opaque data (nil if the update type does not include data).
}

func (JobUpdate) Failed

func (u JobUpdate) Failed() bool

func (JobUpdate) Succeeded

func (u JobUpdate) Succeeded() bool

type JobUpdateCallback

type JobUpdateCallback func(update JobUpdate)

type JobUpdateType

type JobUpdateType int
const (
	JobUpdateTypeData JobUpdateType = iota
	JobUpdateTypeWarning
	JobUpdateTypeStatus
	JobUpdateTypeComplete
	JobUpdateTypeFail
	JobUpdateTypeException
)

func (JobUpdateType) String

func (t JobUpdateType) String() string

type Server

type Server struct {
	// contains filtered or unexported fields
}

func NewServer

func NewServer(ln net.Listener) *Server

func NewServerWithAddr

func NewServerWithAddr(addr string) (*Server, error)

func (*Server) Addr

func (s *Server) Addr() *net.TCPAddr

func (*Server) Stop

func (s *Server) Stop()

func (*Server) Submit

func (s *Server) Submit(r *JobRequest) string

Submit a job and receive its handle.

Directories

Path Synopsis
Package gearmintest provides utilities for testing code that uses gearmin.
Package gearmintest provides utilities for testing code that uses gearmin.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL