gocql_ec2

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2016 License: MIT Imports: 2 Imported by: 0

README

gocql-ec2

The gocql_ec2 package provides Amazon EC2 related functionality for the gocql cassandra driver. Currently this is limited to providing address translation support for multi-region cassandra ring setups, but who knows what else might be useful. Plus, gocql_ec2 is a much more succinct package name than gocql_ec2_address_translator.

Multi-Region Address Translator

The EC2MultiRegionAddressTranslator will attempt to resolve any peer's broadcast address to its private-ip. This works by doing a reverse lookup on the broadcast address -- which should be its public-ip -- then doing an address lookup for any hostname resulting from the reverse lookup. Within the same ec2 region, this will translate the public-ip into a private-ip; outside of the peer's ec2 region, only the public-ip will be returned.

This is typically done to save on costs. It's also useful when your "ring masters" disable public-ip access for connections coming from inside the same network (which they are doing to force you to save on costs).

Usage

Configuring gocql to use this translator is straight-forward; just configure the ClusterConfig.AddressTranslator:

cluster := gocql.NewCluster("node1", "node2")
cluster.AddressTranslator = gocql_ec2.EC2MultiRegionAddressTranslator()
// ...
session := cluster.NewSession()

Testing

Unit tests:

go test github.com/signal/gocql_ec2/...

Integration tests:

./integration.sh ${GOPATH}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EC2MultiRegionAddressTranslator

func EC2MultiRegionAddressTranslator() gocql.AddressTranslator

EC2MultiRegionAddressTranslator will do a reverse DNS lookup on the address provided, then do a DNS lookup on the first hostname found in order to potentially get the private IP of the given address. If no results are found in either lookup, the given address is returned. Port is always returned unchanged. Build with the gocql_debug tag to see address translation at work.

Types

type DNS

type DNS interface {
	LookupAddr(addr string) (names []string, err error)
	LookupHost(host string) (addrs []string, err error)
}

Jump to

Keyboard shortcuts

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