precreator - ActiveState ActiveGo 1.8

Package precreator

import ""

Overview ▾

Package precreator provides the shard precreation service.


const (
    // DefaultCheckInterval is the shard precreation check time if none is specified.
    DefaultCheckInterval = 10 * time.Minute

    // DefaultAdvancePeriod is the default period ahead of the endtime of a shard group
    // that its successor group is created.
    DefaultAdvancePeriod = 30 * time.Minute

type Config

Config represents the configuration for shard precreation.

type Config struct {
    Enabled       bool          `toml:"enabled"`
    CheckInterval toml.Duration `toml:"check-interval"`
    AdvancePeriod toml.Duration `toml:"advance-period"`

func NewConfig

func NewConfig() Config

NewConfig returns a new Config with defaults.

func (Config) Validate

func (c Config) Validate() error

Validate returns an error if the Config is invalid.

type Service

Service manages the shard precreation service.

type Service struct {
    Logger zap.Logger

    MetaClient interface {
        PrecreateShardGroups(now, cutoff time.Time) error
    // contains filtered or unexported fields

func NewService

func NewService(c Config) (*Service, error)

NewService returns an instance of the precreation service.

func (*Service) Close

func (s *Service) Close() error

Close stops the precreation service.

func (*Service) Open

func (s *Service) Open() error

Open starts the precreation service.

func (*Service) WithLogger

func (s *Service) WithLogger(log zap.Logger)

WithLogger sets the logger for the service.