TINE Docs
GitHub
  • Highlights
  • TINE
    • Install
  • GETTING STARTED
    • Quick start
    • Concept
      • Multiple Inlets and Outlets
      • Merge Records
      • Pipeline as Http Handler
    • Log config
  • Embedding TINE in Go
    • Use Recipe
    • Use API
  • Plugins
    • Inlets
    • Flows
    • Outlets
    • Extras
  • RECIPES
    • QRCode Generator
    • OLLAMA
    • OLLAMA Telegram Bot
    • Web Page Snapshot
    • Syslog Receiver
    • SQLite
    • RRD
Powered by GitBook
On this page
Edit on GitHub
  1. Embedding TINE in Go

Use API

Create a pipeline

// import github.com/OutOfBedlam/tine/engine
//
// Create a pipeline
pipeline, err := engine.New(engine.WithName("my_pipeline"))

Set inputs of the pipeline

// import github.com/OutOfBedlam/tine/plugins/psutil
//
// Add inlet for cpu usage
conf := engine.NewConfig().Set("percpu", false).Set("interval", 3 * time.Second)
pipeline.AddInlet("cpu", psutil.CpuInlet(pipeline.Context().WithConfig(conf)))

Set outputs of the pipeline

// import github.com/OutOfBedlam/tine/plugins/base
//
// Add outlet printing to stdout '-'
conf = engine.NewConfig().Set("path", "-").Set("decimal", 2)
pipeline.AddOutlet("file", base.FileOutlet(pipeline.Context().WithConfig(conf)))

Start the pipeline

pipeline.Start()

The Start() function in the code snippet above initiates the pipeline execution but does not wait for it to complete. Instead, it spawns a goroutine by calling go pipeline.Run() and returns immediately. On the other hand, pipeline.Run() is a blocking function that waits until the pipeline finishes its execution before returning control.

PreviousUse RecipeNextInlets

Last updated 9 months ago