coordinator

package
v2.10.0 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2024 License: MIT Imports: 1 Imported by: 0

README

Coordinator

Usage

package main

import (
	"fmt"
	"sync"

	"github.com/go-kratos-ecosystem/components/v2/coordinator"
)

func main() {
	var wg sync.WaitGroup
	wg.Add(3) //nolint:gomnd

	go func() {
		defer wg.Done()
		if <-coordinator.Until("foo").Done(); true {
			fmt.Println("foo")
		}
	}()

	go func() {
		defer wg.Done()
		if <-coordinator.Until("foo").Done(); true {
			fmt.Println("foo 2")
		}
	}()

	go func() {
		defer wg.Done()
		if <-coordinator.Until("bar").Done(); true {
			fmt.Println("bar")
		}
	}()

	coordinator.Until("foo").Close()
	coordinator.Until("bar").Close()

	wg.Wait()
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Clear

func Clear()

func Close

func Close(identifier string)

Types

type Coordinator

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

func NewCoordinator

func NewCoordinator() *Coordinator

func Until

func Until(identifier string) *Coordinator

func (*Coordinator) Close

func (c *Coordinator) Close()

func (*Coordinator) Done

func (c *Coordinator) Done() <-chan struct{}

type Manager

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

func NewManager

func NewManager() *Manager

func (*Manager) Clear

func (m *Manager) Clear()

func (*Manager) Close

func (m *Manager) Close(identifier string)

func (*Manager) Until

func (m *Manager) Until(identifier string) *Coordinator

Jump to

Keyboard shortcuts

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