translator

package
v1.26.0-120.5 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidTranslatorPluginName = errors.New("translator_plugin: invalid translator plugin requested")
)

Functions

func RegisterTranslator

func RegisterTranslator(name string, plugin TranslatorPlugin)

RegisterPlugin adds an auth plugin to the plugin registry it is only safe to use from a package init function

Types

type FixedAddressTranslatorPlugin

type FixedAddressTranslatorPlugin struct {
}

func (*FixedAddressTranslatorPlugin) GetTranslator

GetTranslator What gocql driver does is that it will connect to the first node in the list in configuration (if there is more than one), if it fails to connect to it, it will pick another from that list and so on so. When the connection is initialised, the driver does not know what the topology of a cluster looks like yet. It just connected to a node. In order to know, for the driver itself, internally, what the topology is like, it will query that node it just connected to, and it will read system.peers table. In that table, there are all other nodes of a cluster as that node, gocql just connected to, sees it.

Every other node has the very same system.peers table where all other nodes of the cluster are. The returned rows, representing all other nodes in the cluster, contain IP addresses internal of that cluster. They are not necessarily the same hostnames as the ones you would translate with your service resolver (they are IP addresses, not hostnames, actually).

For the case if the nodes are behind the proxy, service resolver would translate just the publicly visible hostname which a user put into configuration so driver can connect to it, but that is not enough, IP addresses behind a proxy are not reachable from client's perspective. These are not translatable with service resolver so client can not connect to them directly - that is what gocql address translator is exactly for.

The implementation of fixed address translator plugin is fed the internal IP address from the system.peers table, and it will always return same fixed ip based on what advertised-hostname is resolved to. That IP address, from client's perspective, might be, for example, an IP address of a load balancer which is reachable from client. As the IP address of all nodes are some, the difference between the nodes can be achieved by running them on a different port for each node. see also https://github.com/gocql/gocql/pull/1635

type TranslatorPlugin

type TranslatorPlugin interface {
	GetTranslator(*config.Cassandra) (gocql.AddressTranslator, error)
}

TranslatorPlugin interface for Cassandra address translation mechanism

func LookupTranslator

func LookupTranslator(name string) (TranslatorPlugin, error)

func NewFixedAddressTranslatorPlugin

func NewFixedAddressTranslatorPlugin() TranslatorPlugin

Jump to

Keyboard shortcuts

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