Switchyard lets LLM applications route traffic across models and providers while preserving native OpenAI and Anthropic API compatibility - enabling flexible model selection, benchmarking, and cost/performance optimization.
Rust
feat(go): report the compiled routing backend (#1147)
Alex Fournier52e32ec9e93a
diff --git a/bindings/go/README.md b/bindings/go/README.mdindex 39ee6b6bd..b3ed63ddd 100644--- a/bindings/go/README.md+++ b/bindings/go/README.md@@ -70,6 +70,7 @@ Import `encoding/json` andThe backend is selected at build time: `cgo` with `switchyard_native` uses thenative library; other builds use WASM. Both use `New(config)` and the same routing API.+Call `Backend()` to report `"native"` or `"wasm"` without creating a router.Supply the model groups needed by the configured algorithm. Composite needs`any` for eligible answer targets, plus `capable`, `efficient`, and `judge`.diff --git a/bindings/go/backend_native.go b/bindings/go/backend_native.goindex 380d62ad9..c8ad6c493 100644--- a/bindings/go/backend_native.go+++ b/bindings/go/backend_native.go@@ -26,6 +26,9 @@ import ("unsafe")+// Backend returns the compiled routing backend: "native" or "wasm".+func Backend() string { return "native" }+type nativeBackend struct {mu sync.RWMutexptr *C.SyRouterdiff --git a/bindings/go/backend_native_test.go b/bindings/go/backend_native_test.gonew file mode 100644index 000000000..18a7b3957--- /dev/null+++ b/bindings/go/backend_native_test.go@@ -0,0 +1,14 @@+// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.+// SPDX-License-Identifier: Apache-2.0++//go:build cgo && switchyard_native++package switchyard++import "testing"++func TestBackend(t *testing.T) {+ if got := Backend(); got != "native" {+ t.Fatalf("Backend() = %q, want native", got)+ }+}diff --git a/bindings/go/backend_wazero.go b/bindings/go/backend_wazero.goindex 30ffa6150..10663254c 100644--- a/bindings/go/backend_wazero.go+++ b/bindings/go/backend_wazero.go@@ -18,6 +18,9 @@ import ("time")+// Backend returns the compiled routing backend: "native" or "wasm".+func Backend() string { return "wasm" }+type wasmBackend struct {runtime *wasmRuntimeslots []*wasmSlotdiff --git a/bindings/go/wasm_test.go b/bindings/go/wasm_test.goindex aad517456..96dec387d 100644--- a/bindings/go/wasm_test.go+++ b/bindings/go/wasm_test.go@@ -83,6 +83,12 @@ func TestWasmCancellationBeforeOutcome(t *testing.T) {}}+func TestBackend(t *testing.T) {+ if got := Backend(); got != "wasm" {+ t.Fatalf("Backend() = %q, want wasm", got)+ }+}+// Parent and child identities must share the guest that owns their session state.func TestWasmSessionAffinity(t *testing.T) {backend := &wasmBackend{slots: []*wasmSlot{{}, {}}}