nsqx

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: May 8, 2022 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Overview

Package nsqx is a generated GoMock package.

Index

Constants

View Source
const TimeoutDuration = time.Second * 60

Variables

This section is empty.

Functions

This section is empty.

Types

type Consumer

type Consumer struct {
	Topic   string
	Channel string
	Method  string
	// contains filtered or unexported fields
}

func NewConsumer

func NewConsumer(
	ctrl *ConsumerController,
	topic, channel string,
	config *ConsumerConfiguration,
	consumer ConsumerItf,
) *Consumer

func (*Consumer) HandleMessage

func (c *Consumer) HandleMessage(message *nsq.Message) error

type ConsumerConfiguration

type ConsumerConfiguration struct {
	NSQ           *nsq.Config
	LookupAddress []string
	Concurrency   int
	MaxInFlight   int
	MaxAttempts   uint16
}

func (*ConsumerConfiguration) Validate

func (c *ConsumerConfiguration) Validate() error

type ConsumerController

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

func NewConsumerController

func NewConsumerController(interceptors ...ConsumerInterceptor) *ConsumerController

func (*ConsumerController) AddConsumers

func (c *ConsumerController) AddConsumers(params []ConsumerParam) error

func (*ConsumerController) Serve

func (c *ConsumerController) Serve()

type ConsumerHandler

type ConsumerHandler func(ctx context.Context, consumer *Consumer) error

ConsumerHandler is the handler definition to run a consumer.

type ConsumerInterceptor

type ConsumerInterceptor func(ctx context.Context, consumer *Consumer, handler ConsumerHandler) error

ConsumerInterceptor is the middleware that will be executed before the current handler.

func ConsumerChain

func ConsumerChain(interceptors ...ConsumerInterceptor) ConsumerInterceptor

ConsumerChain returns a single interceptor from multiple interceptors.

type ConsumerItf

type ConsumerItf interface {
	Handle(ctx context.Context, message *nsq.Message) error
}

ConsumerItf is consumer interface to consume nsq message.

type ConsumerParam

type ConsumerParam struct {
	Topic    string
	Channel  string
	Config   *ConsumerConfiguration
	Consumer ConsumerItf
}

type FuncConsumer

type FuncConsumer func(ctx context.Context, message *nsq.Message) error

FuncConsumer is a type to allow callers to wrap a raw func.

func (FuncConsumer) Handle

func (r FuncConsumer) Handle(ctx context.Context, message *nsq.Message) error

type MockConsumerItf

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

MockConsumerItf is a mock of ConsumerItf interface.

func NewMockConsumerItf

func NewMockConsumerItf(ctrl *gomock.Controller) *MockConsumerItf

NewMockConsumerItf creates a new mock instance.

func (*MockConsumerItf) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockConsumerItf) Handle

func (m *MockConsumerItf) Handle(ctx context.Context, message *nsq.Message) error

Handle mocks base method.

type MockConsumerItfMockRecorder

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

MockConsumerItfMockRecorder is the mock recorder for MockConsumerItf.

func (*MockConsumerItfMockRecorder) Handle

func (mr *MockConsumerItfMockRecorder) Handle(ctx, message interface{}) *gomock.Call

Handle indicates an expected call of Handle.

type MockProducerItf

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

MockProducerItf is a mock of ProducerItf interface.

func NewMockProducerItf

func NewMockProducerItf(ctrl *gomock.Controller) *MockProducerItf

NewMockProducerItf creates a new mock instance.

func (*MockProducerItf) DeferredPublish

func (m *MockProducerItf) DeferredPublish(ctx context.Context, topic string, delay time.Duration, data interface{}) error

DeferredPublish mocks base method.

func (*MockProducerItf) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockProducerItf) Publish

func (m *MockProducerItf) Publish(ctx context.Context, topic string, data interface{}) error

Publish mocks base method.

type MockProducerItfMockRecorder

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

MockProducerItfMockRecorder is the mock recorder for MockProducerItf.

func (*MockProducerItfMockRecorder) DeferredPublish

func (mr *MockProducerItfMockRecorder) DeferredPublish(ctx, topic, delay, data interface{}) *gomock.Call

DeferredPublish indicates an expected call of DeferredPublish.

func (*MockProducerItfMockRecorder) Publish

func (mr *MockProducerItfMockRecorder) Publish(ctx, topic, data interface{}) *gomock.Call

Publish indicates an expected call of Publish.

type Producer

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

func NewProducer

func NewProducer(config *ProducerConfiguration) (*Producer, error)

NewProducer creates a client to publish message to nsq.

func (*Producer) DeferredPublish

func (p *Producer) DeferredPublish(
	_ context.Context,
	topic string,
	delay time.Duration,
	data interface{},
) error

DeferredPublish sends data to nsq after certain delay.

func (*Producer) Publish

func (p *Producer) Publish(_ context.Context, topic string, data interface{}) error

Publish sends data to nsq.

type ProducerConfiguration

type ProducerConfiguration struct {
	NSQ           *nsq.Config
	DaemonAddress string
	MaxAttempt    int
}

func (*ProducerConfiguration) Validate

func (p *ProducerConfiguration) Validate() error

type ProducerItf

type ProducerItf interface {
	// Publish sends data to nsq.
	// Data should be json bytes but the struct or map.
	Publish(ctx context.Context, topic string, data interface{}) error

	// DeferredPublish sends data to nsq after certain delay.
	DeferredPublish(ctx context.Context, topic string, delay time.Duration, data interface{}) error
}

ProducerItf is producer interface to publish nsq message.

Directories

Path Synopsis
example

Jump to

Keyboard shortcuts

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