uq

package
v0.0.0-...-04b8071 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2016 License: BSD-3-Clause Imports: 12 Imported by: 0

README

gouq

Gouq is the golang library for uq cluster. To use gouq, import the github package in your program:

import (
	"github.com/buaazp/libuq/gouq"
)

Then new a client:

// for single uq instance
c, err = uq.NewClient(protocol, ip, port)
// for multi instances in a cluster
c, err = uq.NewClientEtcd(protocol, etcdServers, cluster)

And use the queue methods like:

err = c.Add(topic, line, recycle)
err = c.Push(topic, value)
id, data, err := c.Pop(key)
err = c.Del(id)

Gouq library will automatically choose the instance online to deal with the queue methods. You needn't to worry about the connections and etcd results.

For more information, take a look at Godoc.org:

https://godoc.org/github.com/buaazp/libuq/gouq

You can also read the sample code in examples/go-uq.go. To run the sample:

go build examples/go-uq.go
./go-uq -h
Usage of ./go-uq:
  -cluster="uq": cluster name in etcd
  -etcd="": etcd service location
  -ip="127.0.0.1": uq server ip address
  -line="x": line name
  -port=8808: uq server port
  -protocol="redis": frontend interface(redis, mc, http)
  -topic="foo": topic name

Documentation

Index

Constants

View Source
const (
	ProtoHttp  string = "http"
	ProtoMc    string = "mc"
	ProtoRedis string = "redis"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

func NewClient

func NewClient(uqProtocol string, uqIp string, uqPort int) (*Client, error)

func NewClientEtcd

func NewClientEtcd(uqProtocol string, etcdAddr []string, etcdKey string) (*Client, error)

func (*Client) Add

func (c *Client) Add(topic, line string, recycle time.Duration) error

func (*Client) Close

func (c *Client) Close()

func (*Client) Del

func (c *Client) Del(key string) error

func (*Client) Pop

func (c *Client) Pop(key string) (string, []byte, error)

func (*Client) Push

func (c *Client) Push(key string, value []byte) error

type Conn

type Conn interface {
	// contains filtered or unexported methods
}

Jump to

Keyboard shortcuts

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