Skip to content

Instantly share code, notes, and snippets.

@hovsep
Last active January 8, 2026 08:40
Show Gist options
  • Select an option

  • Save hovsep/7f7c2da121a46556cd70485c75786643 to your computer and use it in GitHub Desktop.

Select an option

Save hovsep/7f7c2da121a46556cd70485c75786643 to your computer and use it in GitHub Desktop.
FMesh chained api example
// Builder pattern (all chained calls are invoked on the same object):
p := component.New("processor").
WithDescription("main processor").
AddLabel("env", "prod").
AddLabel("tier", "backend").
AddInputs("in1", "in2").
AddOutputs("out1", "out2").
WithActivationFunc(func(this *component.Component) error {
return nil
})
// Seamless chained api pattern (different objects chained):
filteredResults := mesh.ComponentByName("my-component"). // Pick a Component
OutputByName("res"). // Jump to Port
Signals(). // Now jump onto a signals Group
Filter(func(s *signal.Signal) bool {
return s.Labels().ValueIs("cluster", "k8s")
})
// Check error whenever you want
if filteredResults.HasChainableErr() {
fmt.Println("Oh no! The chain errored", filteredResults.ChainableErr())
os.Exit(1)
}
// Continue chaining
payload := filteredResults.First().PayloadOrNil()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment