Files
tasks/chasm/interceptors.go
zeekay 5a601d081b rebrand: go.temporal.io/server -> github.com/hanzoai/tasks
Full module path rebrand from Temporal to Hanzo Tasks:
- go.mod module: github.com/hanzoai/tasks
- All internal Go imports updated (1906 files)
- cmd/server renamed to cmd/tasksd
- Binary name: tasksd (was temporal-server)
- Docker images: hanzoai/tasks (was temporalio/server)
- README rewritten with Hanzo Tasks branding
- LLM.md created with integration notes
- Makefile, goreleaser, CI workflows updated
- go.temporal.io/sdk and go.temporal.io/api imports preserved (separate repos)

Fork of Temporal.io (MIT license).
2026-03-19 10:36:40 -07:00

68 lines
1.9 KiB
Go

package chasm
import (
"context"
"github.com/hanzoai/tasks/common/log"
"github.com/hanzoai/tasks/common/metrics"
"google.golang.org/grpc"
)
// ChasmEngineInterceptor Interceptor that intercepts RPC requests,
// detects CHASM-specific calls and does additional boilerplate processing before
// handing off. Visibility is injected separately with
// ChasmVisibilityInterceptor.
type ChasmEngineInterceptor struct {
engine Engine
logger log.SnTaggedLogger
metricsHandler metrics.Handler
}
func (i *ChasmEngineInterceptor) Intercept(
ctx context.Context,
req any,
info *grpc.UnaryServerInfo,
handler grpc.UnaryHandler,
) (resp any, retError error) {
// Capture panics for any handler method, not just CHASM-specific ones. This could have gone into a separate
// interceptor, but having it here avoids the overhead of adding another layer to the interceptor chain.
defer metrics.CapturePanic(i.logger, i.metricsHandler, &retError)
ctx = NewEngineContext(ctx, i.engine)
return handler(ctx, req)
}
func ChasmEngineInterceptorProvider(
engine Engine,
logger log.Logger,
metricsHandler metrics.Handler,
) *ChasmEngineInterceptor {
return &ChasmEngineInterceptor{
engine: engine,
logger: logger,
metricsHandler: metricsHandler,
}
}
// ChasmVisibilityInterceptor intercepts RPC requests and adds the CHASM
// VisibilityManager to their context.
type ChasmVisibilityInterceptor struct {
visibilityMgr VisibilityManager
}
func (i *ChasmVisibilityInterceptor) Intercept(
ctx context.Context,
req any,
info *grpc.UnaryServerInfo,
handler grpc.UnaryHandler,
) (resp any, retError error) {
ctx = NewVisibilityManagerContext(ctx, i.visibilityMgr)
return handler(ctx, req)
}
func ChasmVisibilityInterceptorProvider(visibilityMgr VisibilityManager) *ChasmVisibilityInterceptor {
return &ChasmVisibilityInterceptor{
visibilityMgr: visibilityMgr,
}
}