package
1.0.0
Repository: https://github.com/asim/mq.git
Documentation: pkg.go.dev

# README

Go Client GoDoc

Usage

Publish

package main

import (
	"log"
	"time"

	"github.com/asim/mq/client"
)

func main() {
	tick := time.NewTicker(time.Second)

	for _ = range tick.C {
		if err := client.Publish("foo", []byte(`bar`)); err != nil {
			log.Println(err)
			break
		}
	}
}

Subscribe

package main

import (
	"log"

	"github.com/asim/mq/client"
)

func main() {
	ch, err := client.Subscribe("foo")
	if err != nil {
		log.Println(err)
		return
	}

	for e := range ch {
		log.Println(string(e))
	}

	log.Println("channel closed")
}

New Client

// defaults to MQ server localhost:8081
c := client.New()

gRPC client

import "github.com/asim/mq/client/grpc"

c := grpc.New()

Clustering

Clustering is supported on the client side. Publish/Subscribe operations are performed against all servers.

c := client.New(
	client.WithServers("10.0.0.1:8081", "10.0.0.1:8082", "10.0.0.1:8083"),
)

Sharding

Sharding is supported via client much like gomemcache. Publish/Subscribe operations are performed against a single server.

import "github.com/asim/mq/client/selector"

c := client.New(
	client.WithServers("10.0.0.1:8081", "10.0.0.1:8082", "10.0.0.1:8083"),
	client.WithSelector(new(selector.Shard)),
)

Resolver

A name resolver can be used to discover the ip addresses of MQ servers

import "github.com/asim/mq/client/resolver"

c := client.New(
	// use the DNS resolver
	client.WithResolver(new(resolver.DNS)),
	// specify DNS name as server
	client.WithServers("mq.proxy.local"),
)

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Functions

New returns a new Client.
Publish via the default Client.
Subscribe via the default Client.
Unsubscribe via the default Client.
WithResolver sets the resolver used to get the server list.
WithRetries sets the number of retry attempts.
WithSelector sets the server selector used by the client.
WithServers sets the servers used by the client.

# Variables

The default client.
The default number of retries.
The default server list.

# Structs

No description provided by the author

# Interfaces

Client is the interface provided by this package.
Resolver resolves a name to a list of servers.
Selector provides a server list to publish/subscribe to.

# Type aliases

No description provided by the author