sync

package
v1.0.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2026 License: MIT Imports: 10 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package sync предоставляет gRPC-сервис для синхронизации хостов.

Этот сервис используется репликами для обмена списками хостов.

Метод:

  • Hosts — обмен списками хостов между репликами

Index

Constants

This section is empty.

Variables

View Source
var Component = compogo.Component{
	Dependencies: compogo.Components{
		&grpcServer.Component,
		&grpc2.Component,
		&manager.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(s *Service, grpc *grpcServer.Server) {

			service.RegisterSyncServer(grpc.GetGRPC(), s)
		})
	}),
}

Component — компонент для регистрации gRPC-сервиса Sync.

Жизненный цикл:

  1. Init — регистрирует конструктор Service в DI-контейнере.
  2. PreExecute — регистрирует Service в gRPC-сервере.

Functions

This section is empty.

Types

type Service

type Service struct {
	service.UnimplementedSyncServer
	// contains filtered or unexported fields
}

Service — реализация gRPC-сервиса Sync.

func NewService

func NewService(
	manager cluster.Manager,
	grpcConfig *grpcClientConfig.Config,
	logger compogo.Logger,
	closer compogo.Closer,
) *Service

NewService создаёт новый сервис Sync.

func (*Service) Hosts

func (s *Service) Hosts(_ context.Context, sync *model.Sync) (*model.Sync, error)

Hosts — обработчик синхронизации хостов.

Принимает список хостов от другой реплики. Возвращает свой список хостов.

Логика:

  1. Получает список хостов от другой реплики.
  2. Сравнивает со своим списком.
  3. Если есть новые хосты — добавляет их через Manager.AddPeer.

Примечание: этот метод вызывается периодически из Process синхронизации.

Jump to

Keyboard shortcuts

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