mongorep

package
v0.0.0-...-0174093 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DependencyKind = "dependency"
	GroupKind      = "group"
)
View Source
const (
	GroupCreated      = "created"
	GroupInitializing = "initializing"
	GroupInitialized  = "initialized"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Dependency

type Dependency struct {
	Doc

	GroupsProcessed bool   `bson:"groups_processed"`
	Status          string `bson:"status"`
}

type Doc

type Doc struct {
	ID        string `bson:"_id"`
	ContextID string `bson:"context_id"`
	Kind      string `bson:"kind"`
	// UnixNano time
	UpdatedAt int64 `bson:"updated_at"`
}

type Group

type Group struct {
	Doc
	Status  string      `bson:"status"`
	Pending Set[string] `bson:"pending"`
	Ready   Set[string] `bson:"ready"`
}

type Manager

type Manager struct {
	Collection    *mongo.Collection
	Broker        *event.Broker
	Logger        *slog.Logger
	EventName     string
	ConsumerGroup string
}

Groups and Dependencies are stored in one collection and are differentiated by the 'kind' field.

func (*Manager) InitializeGroup

func (manager *Manager) InitializeGroup(ctx context.Context, groupId string, dependencyIds ...string) error

func (*Manager) LoadDependencies

func (manager *Manager) LoadDependencies(ctx context.Context, ids ...string) ([]dependency.Dependency, error)

func (*Manager) LoadGroups

func (manager *Manager) LoadGroups(ctx context.Context, ids ...string) ([]dependency.Group, error)

func (*Manager) LoadShallowGroups

func (manager *Manager) LoadShallowGroups(ctx context.Context, ids ...string) ([]Group, error)

func (*Manager) NewDependencies

func (manager *Manager) NewDependencies(ctx context.Context, n int) ([]dependency.Dependency, error)

func (*Manager) NewGroup

func (manager *Manager) NewGroup(ctx context.Context) (groupId string, err error)

func (*Manager) ReadyGroups

func (manager *Manager) ReadyGroups(ctx context.Context) (<-chan string, error)

func (*Manager) Resolve

func (manager *Manager) Resolve(ctx context.Context, values ...dependency.Dependency) error

type Set

type Set[T comparable] map[T]*struct{}

func (Set[T]) Add

func (s Set[T]) Add(values ...T)

func (Set[T]) Remove

func (s Set[T]) Remove(values ...T)

Jump to

Keyboard shortcuts

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