Documentation
¶
Overview ¶
Package election предоставляет gRPC-сервис для выборов лидера.
Этот сервис используется репликами для обмена term и бюллетенями.
Методы:
- Election — синхронизация term (возраста) между репликами
- Vote — обмен бюллетенями для голосования
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Component = compogo.Component{ Dependencies: compogo.Components{ &election.Component, &grpcServer.Component, }, Init: compogo.StepFunc(func(container compogo.Container) error { return container.Provide(NewService) }), PreExecute: compogo.StepFunc(func(container compogo.Container) error { return container.Invoke(func(grpc *grpcServer.Server, s *Service) { service.RegisterElectionServer(grpc.GetGRPC(), s) }) }), }
Component — компонент для регистрации gRPC-сервиса Election.
Жизненный цикл:
- Init — регистрирует конструктор Service в DI-контейнере.
- PreExecute — регистрирует Service в gRPC-сервере.
Зависимости:
- election.Component — бизнес-логика выборов
- grpcServer.Component — gRPC-сервер
Functions ¶
This section is empty.
Types ¶
type Service ¶
type Service struct {
service.UnimplementedElectionServer
// contains filtered or unexported fields
}
Service — реализация gRPC-сервиса Election.
Регистрируется в gRPC-сервере и обрабатывает запросы от других реплик.
func NewService ¶
NewService создаёт новый сервис Election.
func (*Service) Election ¶
Election — обработчик синхронизации term.
Вызывается другой репликой для синхронизации term.
Параметры:
- age — содержит term и хост реплики, которая запрашивает синхронизацию
Возвращает:
- Age — с текущим term текущей реплики и её хостом
Примечание: при получении term запускаются новые выборы (через AgeSync).
Click to show internal directories.
Click to hide internal directories.