Server lifecycle: - Introduce service.Service to manage HTTP + gRPC startup/shutdown - Fix gRPC mutex deadlock in StartServer when port is occupied - Add GracefulStop with 5s timeout before forced Stop in grpc.go - Pre-check HTTP and gRPC port availability in cmd/start.go - Print gRPC server address in startup access-points block gRPC client refactor: - Move token manager and client from tai/grpc/ to grpc/client/ - Add backward-compatible aliases in tai/yao.go and tai/token.go - Update cmd/run.go to import grpc/client directly (no tai dependency) Sandbox v2 docker migration: - Delete sandbox/v2/docker/ (moved to tai repo) - Update sandbox/docker/build.sh hint to point to tai repo - Clean up .gitignore entries for removed docker directory - Temporarily disable SandboxV2Test and BenchmarkSandboxV2 in CI (docker images need rebuild after tai repo migration) Tai integration: - Add direct-mode registration API handlers in tai/api/ - Add heartbeat handler and token management wrappers - Update tai/registry and tai/tunnel for latest protocol - Replace yao-grpc references with tai call in docs Made-with: Cursor
35 lines
1.2 KiB
Go
35 lines
1.2 KiB
Go
package tai
|
|
|
|
import (
|
|
"context"
|
|
|
|
grpcclient "github.com/yaoapp/yao/grpc/client"
|
|
"github.com/yaoapp/yao/grpc/pb"
|
|
)
|
|
|
|
// YaoClient wraps grpc/client.Client for backward compatibility.
|
|
// New code should use grpc/client.Client directly.
|
|
type YaoClient = grpcclient.Client
|
|
|
|
// NewYaoClientFromEnv reads YAO_GRPC_ADDR and token env vars, dials the
|
|
// gRPC server, and returns a connected YaoClient.
|
|
func NewYaoClientFromEnv() (*YaoClient, error) {
|
|
return grpcclient.NewFromEnv()
|
|
}
|
|
|
|
// DialYao connects to a Yao gRPC server at addr with the given TokenManager.
|
|
func DialYao(addr string, tm *TokenManager) (*YaoClient, error) {
|
|
return grpcclient.Dial(addr, tm)
|
|
}
|
|
|
|
// --- Convenience wrappers kept for sandbox/container code ---
|
|
|
|
// Run executes a Yao process via the given client.
|
|
func Run(ctx context.Context, c *YaoClient, process string, args []byte, timeout int32) ([]byte, error) {
|
|
return c.Run(ctx, process, args, timeout)
|
|
}
|
|
|
|
// Shell executes a system command via the given client.
|
|
func Shell(ctx context.Context, c *YaoClient, command string, args []string, env map[string]string, timeout int32) (*pb.ShellResponse, error) {
|
|
return c.Shell(ctx, command, args, env, timeout)
|
|
}
|