Skip to content

Latest commit

 

History

History
93 lines (63 loc) · 2.7 KB

ReadMe.markdown

File metadata and controls

93 lines (63 loc) · 2.7 KB

Gearman

License Go Doc Build Status Go Report Card

Examples

Worker Example

ctx, cancel := context.WithCancel(context.Background())

w := gearman.NewWorker(ctx, nil)
w.AddServers( gearman.NetConn("tcp","localhost:4730") )

w.AddHandler("reverse", gearman.JobHandler(func(payload io.Reader,reply io.Writer) (error){
        buff	:= make([]byte,1<<16)
        s,_	:= payload.Read(buff)
        buff	= buff[0:s]

        for i:=len(buff); i>0; i-- {
                reply.Write([]byte{ buff[i-1] })
        }

        return nil
} ))

<-ctx.Done()

Client Example

ctx, cancel := context.WithCancel(context.Background())
defer cancel()

w := gearman.SingleServerClient(ctx, nil)
w.AddServers( gearman.NetConn("tcp","localhost:4730") )

bytes_val, err_if_any := cli.Submit( NewTask("some task", []byte("some byte encoded payload")) ).Value()

Features

  • Worker Support
  • Client Support
  • Access To Raw Packets
  • Async Client Task with promise

Protocol Support

Protocol Plumbing

The protocol implemented is now https://github.com/gearman/gearmand/blob/master/PROTOCOL

  • Binary only protocol
  • Access Raw Packets

Protocol Porcelain

  • PacketFactory for parsing socket
  • Multi server Worker
  • Single server Client
  • Round Robin Client

License

2-Clause BSD

Benchmarks

PacketFactory on LoopReader

BenchmarkPacketFactoryPkt0size-4    	30000000	        43.8 ns/op	      20 B/op	       1 allocs/op
BenchmarkPacketFactoryPkt1len-4     	30000000	        53.1 ns/op	      33 B/op	       1 allocs/op
BenchmarkPacketFactoryPktcommon-4   	10000000	       145   ns/op	     128 B/op	       2 allocs/op

Unmarshal

BenchmarkUnmarshalPkt0size-4        	100000000	        22.7 ns/op	       8 B/op	       1 allocs/op
BenchmarkUnmarshalPkt1len-4         	30000000	        45.2 ns/op	      48 B/op	       1 allocs/op
BenchmarkUnmarshalPktcommon-4       	20000000	       112   ns/op	      96 B/op	       2 allocs/op

Marshal

BenchmarkMarshalPkt0size-4          	300000000	         4.25 ns/op	       0 B/op	       0 allocs/op
BenchmarkMarshalPkt1len-4           	200000000	         9.70 ns/op	       0 B/op	       0 allocs/op
BenchmarkMarshalPktcommon-4         	200000000	         9.81 ns/op	       0 B/op	       0 allocs/op