alternator

package
v0.0.0-...-3876550 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithSeeds

func WithSeeds(cfg *aws.Config, seeds ...string) *aws.Config
Example
package main

import (
	"github.com/rjeczalik/alternator-aws-go/alternator"

	"github.com/aws/aws-sdk-go/aws"
	"github.com/aws/aws-sdk-go/aws/credentials"
	"github.com/aws/aws-sdk-go/aws/session"
	"github.com/aws/aws-sdk-go/service/dynamodb"
)

func main() {
	cfg := &aws.Config{
		Region:      aws.String("us-east-1"),
		Credentials: credentials.NewStaticCredentials("access-key", "secret-key", ""),
	}

	// The following line configures DynamoDB client to use Scylla Alternator cluster.
	cfg = alternator.WithSeeds(cfg, "172.0.1.11:8000", "172.0.2.11:8000", "172.0.3.11:8000")

	client := dynamodb.New(session.Must(session.NewSession(cfg)))
	_ = client
}
Output:

func WithSeedsContext

func WithSeedsContext(ctx context.Context, cfg *aws.Config, seeds ...string) *aws.Config
Example
package main

import (
	"context"

	"github.com/rjeczalik/alternator-aws-go/alternator"

	"github.com/aws/aws-sdk-go/aws"
	"github.com/aws/aws-sdk-go/aws/credentials"
	"github.com/aws/aws-sdk-go/aws/session"
	"github.com/aws/aws-sdk-go/service/dynamodb"
)

func main() {
	// If DynamoDB client's lifetime is context-bound,
	// we are going to use WithSeedsContext instead.
	// It will clean up the alternator client once
	// the DynamoDB client is terminated.
	ctx := context.TODO()

	cfg := &aws.Config{
		Region:      aws.String("us-east-1"),
		Credentials: credentials.NewStaticCredentials("access-key", "secret-key", ""),
	}

	// The following line configures DynamoDB client to use Scylla Alternator cluster.
	cfg = alternator.WithSeedsContext(ctx, cfg, "172.0.1.11:8000", "172.0.2.11:8000", "172.0.3.11:8000")

	client := dynamodb.New(session.Must(session.NewSession(cfg)))
	_ = client
}
Output:

Types

type Resolver

type Resolver struct {
	PollInterval time.Duration
	Seeds        []string
	// contains filtered or unexported fields
}

func (*Resolver) EndpointFor

func (r *Resolver) EndpointFor(service, region string, opts ...func(*endpoints.Options)) (e endpoints.ResolvedEndpoint, err error)

type Retryer

type Retryer struct {
	Seeds []string
}

func (*Retryer) MaxRetries

func (r *Retryer) MaxRetries() int

func (*Retryer) RetryRules

func (r *Retryer) RetryRules(req *request.Request) time.Duration

func (*Retryer) ShouldRetry

func (r *Retryer) ShouldRetry(req *request.Request) bool

Jump to

Keyboard shortcuts

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