dynostream

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2023 License: MIT Imports: 10 Imported by: 0

README

dynostream

Easy to use Stream Subscriber for DynamoDB

Usage

package main

import (
	"context"
	"log"

	"github.com/0skillallluck/dynostream"
	"github.com/aws/aws-sdk-go/aws/session"
)

func main() {
	// Create a new AWS session
	sess := session.New()

	// Create a new DynoStream
	stream := dynostream.NewFromSession(sess, "my-table")

	// Create a new context for the subscription
	ctx := context.Background()

	// Subscribe to the stream
	channel, errorChannel := stream.Subscribe(ctx)

	// Handle errors
	go func(errCh <-chan error) {
		for err := range errCh {
			log.Println("Error: ", err)
		}
	}(errorChannel)

	// Handle records
	for record := range channel {
		log.Println("Record:", record)
	}
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DynoStream

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

DynoStream is a struct that contains the DynamoDB and DynamoDBStreams interfaces as well as the name of the table to stream from.

func New

New creates a new DynoStream struct from existing DynamoDB and DynamoDBStreams interfaces and the name of the table to stream from.

func NewFromSession

func NewFromSession(sess *session.Session, table string) *DynoStream

NewFromSession creates a new DynoStream struct from an existing AWS session and the name of the table to stream from.

func (*DynoStream) Subscribe

func (ds *DynoStream) Subscribe(ctx context.Context) (<-chan *dynamodbstreams.Record, <-chan error)

Subscribe creates a new subscription to the DynamoDB stream for the table specified in the DynoStream struct. It returns a channel of dynamodbstreams.Record structs and a channel of errors. The dynamodbstreams.Record channel will be closed when the context is closed.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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