Skip to content
/ topic Public

A golang in process sub/pub system inspired by Kafka or redis streams

License

Notifications You must be signed in to change notification settings

ostcar/topic

Repository files navigation

Topic

Actions Status PkgGoDev

Package topic is an in process pubsub system where new values have to be pulled instead of beeing pushed.

The idea of pulling updates is inspired by Kafka or Redis-Streams. A subscriber does not have to register or unsubscribe to a topic and can take as long as it needs to process the messages.

How to use topic

A topic can be created with: top := topic.New[string]().

To publish one or more values, use: top.Publish("info1", "info2").

To receive values for the first time use: id, values, err := top.Receive(ctx, 0). The first value is a numeric id, it is needed for for next call of top.Receive(). The second argument is a list of all values that where published by this topic.

To receive newer values, use id, values, err = top.Receive(ctx, id). It returns all values that published after the given id.

A topic is save for concurrent use.

Run tests

Contibutions are wellcome. Please make sure that the tests are running with:

go test

Who is using topic

Topic was build for OpenSlides and is used in production for the Autoupdate-Service

About

A golang in process sub/pub system inspired by Kafka or redis streams

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages