streams

package module
v0.0.0-...-8997cbf Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2023 License: MIT Imports: 4 Imported by: 0

README

fdb-streams

PkgGoDev CI Go Report Card

An event streaming library for FoundationDB that supports reactive consumers.

API documentation

Tests

Start all the services:

docker compose up -d

Run all tests:

docker compose exec streams go test

Run a specific test:

docker compose exec streams go test -run TestEmit

Sending arguments to go test:

docker compose exec streams go test -cover

MIT License

Copyright (c) 2023 Sune Simonsen mailto:sune@we-knowhow.dk

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Consumer

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

A consumer of a message stream.

func (*Consumer) Next

func (consumer *Consumer) Next() ([]byte, error)

Returns the next message in the stream.

If the stream is already fully consumed, then the method will wait for the next message to be emitted.

type Store

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

func NewStore

func NewStore(db fdb.Database, ns string) (*Store, error)

NewStore constructs a new stream store with the given FoundationDB instance, a namespace ns the streams are stored under.

func (*Store) Stream

func (store *Store) Stream(topic string) (*Stream, error)

Opens a stream for the given topic.

type Stream

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

A message stream.

func (*Stream) Consumer

func (stream *Stream) Consumer(id string) (*Consumer, error)

Returns a consumer for this stream with the given id. If the consumer already exist it will continue from where it left off.

func (*Stream) Emit

func (stream *Stream) Emit(message []byte) error

Emit a message by opening a new transaction.

Notice the message needs to honour the FoundationDB value size limits.

func (*Stream) EmitOn

func (stream *Stream) EmitOn(tr fdb.Transaction, message []byte) error

Emit a message on an open transaction.

Notice the message needs to honour the FoundationDB value size limits.

Jump to

Keyboard shortcuts

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