gearadmin

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

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

Go to latest
Published: Jun 1, 2019 License: Apache-2.0 Imports: 5 Imported by: 2

README

gearadmin

Go bindings to the gearman admin protocol.

Why

If you want to write programs that check the status of gearman itself, you need to interact with the admin protocol.

Documentation

GoDoc.

Tests

gearadmin is built and tested against Go 1.7. Ensure this is the version of Go you're running with go version.

Make sure your GOPATH is set, e.g. export GOPATH=~/go.

The tests run golint automatically, so install that with go get github.com/golang/lint/golint. Ensure that GOPATH/bin is in your PATH so that you can run golint: export PATH=$PATH:$GOPATH/bin.

The Makefile runs commands by specifying the full package name, e.g. go test github.com/Clever/gearadmin. If this repository is not checked out at $GOPATH/src/github.com/Clever/admin, then you will need to create a symlink to run tests:

  • Clone the repository to a location outside your GOPATH, and symlink it to $GOPATH/src/github.com/Clever/gearadmin.
  • If you have gvm installed, you can make this symlink by running the following from the root of where you have cloned the repository: gvm linkthis github.com/Clever/gearadmin.

If you have done all of the above, then you should be able to run

make

Documentation

Overview

Package gearadmin provides simple bindings to the gearman admin protocol: http://gearman.org/protocol/.

Usage

Here's an example program that outputs the status of all worker queues in gearman:

package main

import (
	"fmt"
	"github.com/Clever/gearadmin"
	"net"
)

func main() {
	c, err := net.Dial("tcp", "localhost:4730")
	if err != nil {
		panic(err)
	}
	defer c.Close()
	admin := gearadmin.NewGearmanAdmin(c)
	status, _ := admin.Status()
	fmt.Printf("%#v\n", status)
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GearmanAdmin

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

GearmanAdmin communicates with a gearman server.

func NewGearmanAdmin

func NewGearmanAdmin(connection io.ReadWriter) GearmanAdmin

NewGearmanAdmin takes in a connection and returns an object that interacts with gearman's admin protocol.

func (GearmanAdmin) Status

func (ga GearmanAdmin) Status() ([]Status, error)

Status returns the status of all function queues.

func (GearmanAdmin) Workers

func (ga GearmanAdmin) Workers() ([]Worker, error)

Workers returns a summary of workers connected to gearman.

type Status

type Status struct {
	Function         string
	Total            int
	Running          int
	AvailableWorkers int
}

Status represents the status of a queue for a function as returned by the "status" command.

type Worker

type Worker struct {
	Fd        string
	IPAddress string
	ClientID  string
	Functions []string
}

Worker represents a worker connected to gearman as returned by the "workers" command.

Jump to

Keyboard shortcuts

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