mirror of
https://github.com/hanzoai/tasks.git
synced 2026-11-03 03:56:04 +00:00
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).
58 lines
2.3 KiB
Go
58 lines
2.3 KiB
Go
package frontend
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/gorilla/mux"
|
|
"github.com/hanzoai/tasks/common/dynamicconfig"
|
|
"github.com/hanzoai/tasks/common/headers"
|
|
"github.com/hanzoai/tasks/common/log"
|
|
"github.com/hanzoai/tasks/common/metrics"
|
|
commonnexus "github.com/hanzoai/tasks/common/nexus"
|
|
"github.com/hanzoai/tasks/common/nexus/nexusrpc"
|
|
"github.com/hanzoai/tasks/common/rpc"
|
|
"github.com/hanzoai/tasks/components/nexusoperations"
|
|
"go.uber.org/fx"
|
|
)
|
|
|
|
var Module = fx.Module(
|
|
"component.nexusoperations.frontend",
|
|
fx.Provide(ConfigProvider),
|
|
fx.Provide(commonnexus.NewCallbackTokenGenerator),
|
|
fx.Invoke(RegisterHTTPHandler),
|
|
)
|
|
|
|
func ConfigProvider(coll *dynamicconfig.Collection) *Config {
|
|
return &Config{
|
|
PayloadSizeLimit: dynamicconfig.BlobSizeLimitError.Get(coll),
|
|
ForwardingEnabledForNamespace: dynamicconfig.EnableNamespaceNotActiveAutoForwarding.Get(coll),
|
|
MaxOperationTokenLength: nexusoperations.MaxOperationTokenLength.Get(coll),
|
|
}
|
|
}
|
|
|
|
func RegisterHTTPHandler(options HandlerOptions, logger log.Logger, router *mux.Router) {
|
|
h := nexusrpc.NewCompletionHTTPHandler(nexusrpc.CompletionHandlerOptions{
|
|
Handler: &completionHandler{
|
|
options,
|
|
headers.NewDefaultVersionChecker(),
|
|
options.MetricsHandler.Counter(metrics.NexusCompletionRequestPreProcessErrors.Name()),
|
|
},
|
|
Logger: log.NewSlogLogger(logger),
|
|
Serializer: commonnexus.PayloadSerializer,
|
|
})
|
|
router.Path("/" + commonnexus.RouteCompletionCallback.Representation()).HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
// Limit the request body to max allowed Payload size.
|
|
// Content headers are transformed to Payload metadata and contribute to the Payload size as well. A separate
|
|
// limit is enforced on top of this in the CompleteOperation method.
|
|
r.Body = http.MaxBytesReader(w, r.Body, rpc.MaxNexusAPIRequestBodyBytes)
|
|
h.ServeHTTP(w, r)
|
|
})
|
|
router.Path(commonnexus.PathCompletionCallbackNoIdentifier).HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
// Limit the request body to max allowed Payload size.
|
|
// Content headers are transformed to Payload metadata and contribute to the Payload size as well. A separate
|
|
// limit is enforced on top of this in the CompleteOperation method.
|
|
r.Body = http.MaxBytesReader(w, r.Body, rpc.MaxNexusAPIRequestBodyBytes)
|
|
h.ServeHTTP(w, r)
|
|
})
|
|
}
|