Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bindings/go/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ Import `encoding/json` and

The backend is selected at build time: `cgo` with `switchyard_native` uses the
native 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`.
Expand Down
3 changes: 3 additions & 0 deletions bindings/go/backend_native.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.RWMutex
ptr *C.SyRouter
Expand Down
14 changes: 14 additions & 0 deletions bindings/go/backend_native_test.go
Original file line number Diff line number Diff line change
@@ -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)
}
}
3 changes: 3 additions & 0 deletions bindings/go/backend_wazero.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ import (
"time"
)

// Backend returns the compiled routing backend: "native" or "wasm".
func Backend() string { return "wasm" }

type wasmBackend struct {
runtime *wasmRuntime
slots []*wasmSlot
Expand Down
6 changes: 6 additions & 0 deletions bindings/go/wasm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{{}, {}}}
Expand Down
Loading