mapper

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2016 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Executor

type Executor interface {
	// BrokerConn returns a broker connection used by the executor.
	BrokerConn() *sarama.Broker
	// Stop synchronously stops the executor.
	Stop()
}

Executor represents an entity that executes requests of partition workers via a particular broker connection.

type Resolver

type Resolver interface {
	// ResolveBroker returns a broker connection that should be used to
	// determine a broker executor assigned to the specified partition worker.
	ResolveBroker(pw Worker) (*sarama.Broker, error)
	// SpawnExecutor spawns a broker executor for the specified connection.
	SpawnExecutor(brokerConn *sarama.Broker) Executor
}

Resolver defines an interface to resolve a broker connection that should serve requests of a particular partition worker and create a broker executor from a broker connection.

type T

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

T maintains mapping of partition workers that generate requests to broker executors that process them. It uses an external resolver to determine a particular broker executor instance to assign to a partition worker.

Mapper triggers reassignment whenever one of the following events happen:

  • it is signaled that a new worker has been spawned via `WorkerSpawned()`;
  • it is signaled that an existing worker has stopped via `WorkerStopped()`;
  • a worker explicitly requested reassignment via `WorkerReassign()`
  • an executor reported connection error via `BrokerFailed()`.

Broker executors are spawned on demand when a broker connection is mapped to a partition worker for the first time. It is guaranteed that a broker executor is stopped only after all partition workers that used to be assigned to it have either been stopped or assigned another broker executor.

func Spawn

func Spawn(namespace *actor.ID, resolver Resolver) *T

Spawn creates a mapper instance and starts its internal goroutines.

func (*T) Stop

func (m *T) Stop()

func (*T) WorkerReassign

func (m *T) WorkerReassign() chan<- Worker

func (*T) WorkerSpawned

func (m *T) WorkerSpawned() chan<- Worker

func (*T) WorkerStopped

func (m *T) WorkerStopped() chan<- Worker

type Worker

type Worker interface {
	// assignment returns a channel that the worker expects broker assignments
	// at. Implementations have to ensure that the channel has a non zero buffer
	// and that they read from this channel as soon as the value becomes
	// available, for mapper will drop assignments in case the write to the
	// channel may block.
	Assignment() chan<- Executor
}

Worker represents an entity that makes requests via an assigned broker executor.

Jump to

Keyboard shortcuts

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