duplicator

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2023 License: MIT Imports: 6 Imported by: 0

README

Duplicator

Duplicator module repeats signal from one of inputs to all outputs

Usage

Usage of duplicator module is described by the example.

To import module in your code write following line:

import "github.com/dipdup-net/indexer-sdk/pkg/modules/duplicator"

Duplicator module implements interface Module. So you can use it like any other module. For example:

// create duplicator module with 2 inputs and 2 outputs. Any signal from one of 2 output will be passed to 2 outputs.
duplicatorModule, err := duplicator.NewModule(2, 2)
if err != nil {
    log.Panic(err)
}
// start duplicator module
duplicatorModule.Start(ctx)

// your code is here

// close duplicator module
if err := duplicatorModule.Close(); err != nil {
    log.Panic(err)
}

Input

Module reply to its outputs all signals from inputs. You should connect it with next code:

// with helper function. You should pass a input number to function GetInputName for receiving input name

if err := modules.Connect(customModule, dup, "your_output_of_module", duplicator.GetInputName(0)); err != nil {
    log.Panic(err)
}

Output

You should connect it with next code:

// with helper function. You should pass a output number to function GetOutputName for receiving output name

if err := modules.Connect(dup, customModule, duplicator.GetOutputName(0), "your_output_of_module"); err != nil {
    log.Panic(err)
}

Documentation

Index

Constants

View Source
const (
	InputName  = "input"
	OutputName = "output"
)

names

Variables

This section is empty.

Functions

func GetInputName

func GetInputName(idx int) string

GetInputName -

func GetOutputName

func GetOutputName(idx int) string

GetOutputName -

Types

type Duplicator

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

Duplicator - the structure which is responsible for duplicate signal from one of inputs to all outputs

func NewDuplicator

func NewDuplicator(inputsCount, outputsCount int) *Duplicator

NewDuplicator - constructor of Duplicator structure

func (*Duplicator) AttachTo

func (duplicator *Duplicator) AttachTo(name string, input *modules.Input) error

AttachTo - attach input to output with name

func (*Duplicator) Close

func (duplicator *Duplicator) Close() error

Close - gracefully stops module

func (*Duplicator) Input

func (duplicator *Duplicator) Input(name string) (*modules.Input, error)

Input - returns input by name

func (*Duplicator) Name

func (duplicator *Duplicator) Name() string

Name -

func (*Duplicator) Output

func (duplicator *Duplicator) Output(name string) (*modules.Output, error)

Output - returns output by name

func (*Duplicator) Start

func (duplicator *Duplicator) Start(ctx context.Context)

Start - starts module

Jump to

Keyboard shortcuts

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