lognsq

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

package lognsq provides redirection of messages to a nsqd TCP service. It is used, for example, for aggregating logs from several server instances.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// PrintLogs enables printing of logs to STDERR.
	PrintLogs bool

	// Topic sets a namespace for messages.
	Topic string

	// NsqdURL is the URL to http service of an nsqd daemon
	NsqdURL string
}

Config provides data necessary to start NSQ session. NSQ is a distributed messaging service.

type LogNSQ

type LogNSQ struct {
	Config
	*nsq.Producer
}

LogNSQ creates a "producer" to the nsqd service. The producer is able to publish messages to nsqd. It cannot consume the messages. If the same config is used for many different apps, all of them are able to contribute their logs to the same namespace using nsqd.

func New

func New(cfg Config) (l *LogNSQ, err error)

New Creates a new LogNSQ instance. If creation of "producer" failed, it returns an error.

func (*LogNSQ) Write

func (l *LogNSQ) Write(bs []byte) (n int, err error)

Write takes a slice of bytes and publishes it to STDERR as well as to nsqd service. It uses Topic given in the config.

Jump to

Keyboard shortcuts

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