targeted_commands

command
v0.0.0-...-c509061 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2024 License: GPL-3.0 Imports: 7 Imported by: 0

README

Example 2: tagged conductor used to selectively control groups of routines

This example shows how to use a conductor created with conductor.TaggedFromContext to control groups of running tasks, grouped by "color".

Start the example in a terminal, redirecting to a file the standard error

$ go run main.go 2>/tmp/coordinated.out
> 

In another terminal, follow the lines output in /tmp/coordinated.out (you will need a terminal that supports vt100 escapes).

$ tail -f /tmp/coordinated.log

In the first terminal you will be prompted to control the execution of the program. You can add a colored task with the syntax add <color> [interval]. The color parameter is mandatory, the interval is optional and defaults to 1s. For example

> add red
OK
> add red 1.5s
OK
> add white
OK
> add green 3s
OK

You will begin to see colored lines being output on the second terminal. Now you can control the execution of the program with the following commands

stop [color]
reset [color]
start [color]

If color is not specified, the command is broadcast to all colors.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

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