nsqparse

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

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

Go to latest
Published: Feb 27, 2022 License: GPL-3.0 Imports: 8 Imported by: 0

README

NSQ URL Parser

go.dev reference

Parser for storing NSQ connection information in url format. Example:

nsqd://nsq.server:4150/topic/channel

Example of code usage:

package main

import (
  "github.com/bryanaustin/nsqparse"
  "github.com/nsqio/go-nsq"
)

func main() {
  nu, err := nsqparse.Parse("localhost:4150/topic")
  if err != nil {
    // handle error
  }
  nsqconfig := nsq.NewConfig()
  consumer, err = nu.Consumer(nsqconfig)
  if err != nil {
    // handle error
  }
  consumer.AddHandler(...)
  err = nu.ConnectConsumer(consumer)
  if err != nil {
    // handle error
  }
  // running
}

Documentation

Overview

Parse strings for NSQ connections.

Index

Constants

View Source
const (
	DefaultScheme                = "tcp"
	DefaultAddress               = "localhost:4150"
	DefaultPort                  = ":4150"
	MagicErrorWordsOfPortMissing = "missing port in address"
)

Variables

View Source
var (
	NoTopic = errors.New("no topic")
)

Functions

This section is empty.

Types

type Details

type Details struct {
	Scheme  string
	Address string
	Topic   string
	Channel string
}

func Parse

func Parse(addr string) (d *Details, err error)

Parse URL

func ParseNoDefaults

func ParseNoDefaults(addr string) (d *Details, err error)

ParseNoDefaults will parse and not fill in missing fields with defaults

func ParseStrict

func ParseStrict(addr string) (d *Details, err error)

ParseStrict throws an error if topic is not provided

func (*Details) ConnectConsumer

func (d *Details) ConnectConsumer(c *nsq.Consumer) error

ConnectConsumer will connect this consumer using provided details

func (*Details) Consumer

func (d *Details) Consumer(c *nsq.Config) (*nsq.Consumer, error)

Consumer will make an NSQ consumer with your details

func (*Details) Producer

func (d *Details) Producer(c *nsq.Config) (*nsq.Producer, error)

Producer will make a NSQ producer with the provided details

Jump to

Keyboard shortcuts

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