reaper

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: 12 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 reaper реализует сборщик "мёртвых" реплик.

Reaper — это механизм автоматической очистки кластера от реплик, которые долго находятся в статусе Disconnection.

Принцип работы:

  1. Reaper подписывается на изменения статуса Peer'ов.
  2. Когда Peer переходит в Disconnection, он добавляется в очередь ожидания.
  3. Если за время Wait Peer не вернулся в Ready, он удаляется из кластера.
  4. Reaper проверяет очередь каждые Delay секунд.

Важно: реплики из discovery (оригинальный список хостов) не удаляются. Это гарантирует, что кластер не "потеряет" свои базовые узлы.

Index

Constants

This section is empty.

Variables

View Source
var Component = compogo.Component{
	Name: "cluster.reaper",
	Dependencies: compogo.Components{
		&reaper.Component,
		&repeater.Component,
		&discovery.Component,
	},
	Init: compogo.StepFunc(func(container compogo.Container) error {
		return container.Provide(NewReaper)
	}),
	PostExecute: compogo.StepFunc(func(container compogo.Container) error {
		return container.Invoke(func(m cluster.Manager, reaper *Reaper) {

			m.OnAddPeer().Subscribe(reaper.onAddPeer)
			m.OnDeletingPeer().Subscribe(reaper.onDeletingPeer)
		})
	}),
	Execute: compogo.StepFunc(func(container compogo.Container) error {
		return container.Invoke(func(r repeater.Repeater, reaperConfig *reaper.Config, reaper *Reaper) error {

			return r.AddProcess(repeater.NewTask("cluster.reaper", reaperConfig.Delay, reaper.Process))
		})
	}),
}

Component - компонент сборщика мёртвых узлов для Compogo.

Компонент подписывается на события добавления и удаления Peer'ов, а также запускает периодическую задачу для проверки очереди ожидания.

Functions

This section is empty.

Types

type Reaper

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

Reaper — сборщик мёртвых узлов.

Отслеживает Peer'ов в статусе Disconnection и удаляет их, если они не восстанавливаются в течение заданного времени.

func NewReaper

func NewReaper(config *reaper.Config, manager cluster.Manager, discoveryConfig *discovery.Config) *Reaper

NewReaper создаёт новый сборщик мёртвых узлов.

Принимает:

  • config — конфигурация (Wait, Delay)
  • manager — менеджер кластера
  • discoveryConfig — конфиг discovery (для получения оригинальных хостов)

func (*Reaper) Process

func (r *Reaper) Process(_ context.Context) (err error)

Process — основная задача Reaper (запускается через Repeater).

Проверяет очередь ожидания и удаляет реплики, у которых истёк таймаут. Вызывается каждые config.Delay секунд.

Jump to

Keyboard shortcuts

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