stan_reconnect

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

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

Go to latest
Published: Feb 6, 2020 License: Apache-2.0 Imports: 5 Imported by: 0

README

stan.reconnect

  • reconnect plugin for stan.go
example
package main

import (
    "fmt"
    "github.com/nats-io/stan.go"
    stan_reconnect "github.com/lambdaxs/stan.reconnect"
)

func main() {
    sc, err := stan_reconnect.Connect("c1", "server-host-2", stan.NatsURL("nats://127.0.0.1:4222"))
    if err != nil {
        fmt.Println("err:" + err.Error())
        return
    }


    startOpt := stan.DeliverAllAvailable()
    _, err = sc.QueueSubscribe("foo", "consumer_group_1", func(msg *stan.Msg) {
        fmt.Printf("receive msg:%s time:%d seq:%d\n", string(msg.Data), msg.Timestamp, msg.Sequence)
        msg.Ack()
    }, startOpt, stan.DurableName("consumer_1"), stan.SetManualAckMode())
    if err != nil {
        fmt.Println(err.Error())
        return
    }
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Connection

type Connection struct {
	stan.Conn
	// contains filtered or unexported fields
}

func Connect

func Connect(cid string, clientID string, options ...stan.Option) (*Connection, error)

func (*Connection) Close

func (c *Connection) Close() error

func (*Connection) IsClosed

func (c *Connection) IsClosed() bool

func (*Connection) NatsConn

func (c *Connection) NatsConn() *nats.Conn

func (*Connection) Publish

func (c *Connection) Publish(subject string, data []byte) error

func (*Connection) PublishAsync

func (c *Connection) PublishAsync(subject string, data []byte, ah stan.AckHandler) (string, error)

func (*Connection) QueueSubscribe

func (c *Connection) QueueSubscribe(subject, qgroup string, cb stan.MsgHandler, opts ...stan.SubscriptionOption) (stan.Subscription, error)

func (*Connection) Subscribe

func (c *Connection) Subscribe(subject string, cb stan.MsgHandler, opts ...stan.SubscriptionOption) (stan.Subscription, error)

Directories

Path Synopsis
example
pub
sub

Jump to

Keyboard shortcuts

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