Help us shape the future of Go! Take the 2026 Go Developer Survey

go-stream-client

module
v0.0.0-...-cf8491c Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2021 License: Apache-2.0

README

GO stream client for RabbitMQ streaming queues


Build codecov

Experimental client for RabbitMQ Stream Queues

Download

go get -u github.com/gsantomaggio/rabbitmq-stream-go-client@v0.3-alpha
How to test

  • Run RabbitMQ docker image with streaming:
    docker run -it --rm --name rabbitmq -p 5551:5551 -p 5672:5672 -p 15672:15672 \
    -e RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS="-rabbitmq_stream advertised_host localhost" \
    pivotalrabbitmq/rabbitmq-stream
    
    
  • Run getting started example:
     go run examples/getting_started.go
    
Performance Test

The performance tool is work in progress, you can use it with docker

docker run --network host -it pivotalrabbitmq/go-stream-perf-test silent 

or directly

go run perfTest/perftest.go 
API

client, err := streaming.NewClientCreator().Uri(uris).Connect() // Create and Connect a client
err = client.StreamCreator().Stream(streamName).Create() // Create streaming queue without parameters
err = client.StreamCreator().Stream(streamName).MaxAge(120 * time.Hour).Create() // Create streaming queue with Max Age
err = client.StreamCreator().Stream(streamName).MaxLengthBytes(streaming.ByteCapacity{}.B(5)).Create() // Create streaming queue 5 GB max lenght
/// Implement a consumer
consumer, err := client.ConsumerCreator().
		Stream(streamName).
		Name("my_consumer").
		MessagesHandler(func(context streaming.ConsumerContext, message *amqp.Message) {
			fmt.Printf("received %d, message %s \n", context.Consumer.ID, message.Data)
		}).Build()
/// get a producer
producer, err := client.ProducerCreator().Stream(streamName).Build()
Build from source

make build
Methods Implemented:

  • Open(vhost)
  • CreateStream
  • DeleteStream
  • DeclarePublisher
  • Close Publisher
  • Publish
  • Subscribe
  • Commit
  • UnSubscribe
  • HeartBeat
Work in Progress

The POC is a work in progress, the code isn't too accurate

Directories

Path Synopsis
cmd
pkg

Jump to

Keyboard shortcuts

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