Returns true if string A equals string B (case-sensitive).
| Field | Type | Description |
|---|---|---|
A | *string | First string |
B | *string | Second string |
| Field | Type | Description |
|---|---|---|
Match | bool | True when A == B |
Checks whether a routed department string exactly equals "billing" to gate a downstream billing workflow.
package main
import (
"context"
"encoding/json"
"log"
"os"
"time"
"github.com/akennis/sparsi-go/library"
_ "github.com/akennis/dagor/operator/builtin"
"github.com/panjf2000/ants/v2"
"github.com/akennis/dagor"
"github.com/akennis/dagor/graph"
)
func main() {
dept, expected := "billing", "billing"
library.RegisterConst("dept_val", dept)
library.RegisterConst("expected_val", expected)
g, err := graph.NewBuilder("streq_demo").
Vertex("src_a").Op("dept_val").Output("Result", "wire_a").
Vertex("src_b").Op("expected_val").Output("Result", "wire_b").
Vertex("check").Op("IfStringEqOp").
Input("A", "wire_a").Input("B", "wire_b").
Output("Match", "is_billing").
Build()
if err != nil {
log.Fatalf("build: %v", err)
}
pool, err := ants.NewPool(4)
if err != nil {
log.Fatalf("pool: %v", err)
}
defer pool.Release()
eng, err := dagor.NewEngine(g, pool)
if err != nil {
log.Fatalf("engine: %v", err)
}
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
defer cancel()
if err := eng.Run(ctx); err != nil {
log.Fatalf("run: %v", err)
}
out := map[string]any{"department": dept, "expected": expected}
if raw, ok := eng.GetOutput("is_billing"); ok {
out["is_billing"] = *raw.(*bool)
}
enc := json.NewEncoder(os.Stdout)
enc.SetIndent("", " ")
enc.Encode(out)
}