some fixes

This commit is contained in:
Julius Park
2026-03-16 15:08:42 -04:00
parent 48e393953a
commit 866d62a693
19 changed files with 26 additions and 3 deletions
+1
View File
@@ -35,6 +35,7 @@ func main() {
return &AffinityOutput{Worker: ctx.Worker().ID()}, nil
})
_ = func() error {
// > AffinityRun
result, runErr := affinityWorkflow.RunNoWait(context.Background(), nil,
+2
View File
@@ -75,6 +75,7 @@ func Child(client *hatchet.Client) *hatchet.StandaloneTask {
)
}
func main() {
client, err := hatchet.NewClient()
if err != nil {
@@ -126,6 +127,7 @@ func main() {
return err
}
_ = childResult
n := 5
@@ -14,3 +14,4 @@ func pushEvent(client *hatchet.Client) {
"source": "webhook",
})
}
@@ -15,3 +15,4 @@ func pushApproval(client *hatchet.Client, runID string, approved bool, reason st
"reason": reason,
})
}
@@ -22,3 +22,4 @@ func Embed(ctx context.Context, text string) ([]float32, error) {
}
return resp.Data[0].Embedding, nil
}
@@ -34,3 +34,4 @@ func Complete(ctx context.Context, messages []openai.ChatCompletionMessage) (map
"done": len(toolCalls) == 0,
}, nil
}
@@ -14,3 +14,4 @@ func ParseDocument(content []byte) (string, error) {
defer client.Close()
return client.SetImageFromBytes(content).GetText()
}
@@ -20,3 +20,4 @@ func scheduleOneTime(client *hatchet.Client) {
log.Printf("failed to schedule: %v", err)
}
}
+1
View File
@@ -16,3 +16,4 @@ func runAndSubscribe(client *hatchet.Client) {
fmt.Print(chunk)
}
}
+1
View File
@@ -38,6 +38,7 @@ func main() {
return &StepOutput{Status: "success"}, nil
})
worker, err := client.NewWorker("slot-release-worker", hatchet.WithWorkflows(workflow))
if err != nil {
log.Fatalf("failed to create worker: %v", err)
+1
View File
@@ -45,6 +45,7 @@ func ProcessImageMergent(req MergentRequest) (*MergentResponse, error) {
}, nil
}
// > After (Hatchet)
type ImageProcessInput struct {
ImageURL string `json:"image_url"`
+3
View File
@@ -40,6 +40,7 @@ func Lower(client *hatchet.Client) *hatchet.StandaloneTask {
)
}
// > Accessing the filter payload
func accessFilterPayload(ctx hatchet.Context, input EventInput) (*LowerTaskOutput, error) {
fmt.Println(ctx.FilterPayload())
@@ -48,6 +49,7 @@ func accessFilterPayload(ctx hatchet.Context, input EventInput) (*LowerTaskOutpu
}, nil
}
// > Declare with filter
func LowerWithFilter(client *hatchet.Client) *hatchet.StandaloneTask {
return client.NewStandaloneTask(
@@ -64,6 +66,7 @@ func LowerWithFilter(client *hatchet.Client) *hatchet.StandaloneTask {
)
}
func Upper(client *hatchet.Client) *hatchet.StandaloneTask {
return client.NewStandaloneTask(
"upper", func(ctx hatchet.Context, input EventInput) (*UpperTaskOutput, error) {
+2
View File
@@ -48,6 +48,7 @@ func StickyDag(client *hatchet.Client) *hatchet.Workflow {
return stickyDag
}
type ChildInput struct {
N int `json:"n"`
}
@@ -90,3 +91,4 @@ func Sticky(client *hatchet.Client) *hatchet.StandaloneTask {
return sticky
}
+1
View File
@@ -34,3 +34,4 @@ func main() {
fmt.Println("\nStreaming completed!")
}
+1
View File
@@ -54,3 +54,4 @@ func main() {
log.Println("Failed to start server:", err)
}
}
+1
View File
@@ -46,6 +46,7 @@ func StreamTask(ctx hatchet.Context, input StreamTaskInput) (*StreamTaskOutput,
}, nil
}
func StreamingWorkflow(client *hatchet.Client) *hatchet.StandaloneTask {
return client.NewStandaloneTask("stream-example", StreamTask)
}
+1 -1
View File
@@ -8,7 +8,7 @@
"lint:fix": "eslint . --fix"
},
"dependencies": {
"@hatchet-dev/typescript-sdk": "^1.16.0",
"@hatchet-dev/typescript-sdk": "^1.17.0",
"@anthropic-ai/sdk": "^0.32.1",
"@ai-sdk/openai": "^1.0.0",
"@browserbasehq/sdk": "^2.7.0",
@@ -6,6 +6,8 @@ description: Push events and trigger tasks from external sources.
# External Events
Integrate external event sources to trigger and coordinate tasks.
For example, you could execute any number of tasks in response to a user signup by
declaring the "user:signup" event type as triggers to each of the tasks, and then pushing an event when a user signs up.
- [Pushing Events](/v1/external-events/pushing-events) — Send events to Hatchet
- [Event Trigger](/v1/external-events/run-on-event) — Trigger tasks on events
@@ -5,7 +5,8 @@ import { snippets } from "@/lib/generated/snippets";
## Invoking Tasks From Other Services
While Hatchet recommends importing your workflows and standalone tasks directly to use for triggering runs, this only works in a monorepo or similar setups where you have access to those objects. However, it's common to have a polyrepo, have code written in multiple languages, or otherwise not be able to import your workflows and standalone tasks directly. Hatchet provides first-class, type-safe support for handling these cases as well, with only minor code duplication, to allow you to trigger your tasks from anywhere in a type-safe way.
While Hatchet recommends importing your workflows and standalone tasks directly to use for triggering runs, this only works in a monorepo or similar setups where you have access to those objects. However, it's common to have a polyrepo, have code written in multiple languages, or otherwise not be able to import your workflows and standalone tasks directly.
Hatchet provides stub tasks for these cases, allowing you to trigger your tasks from anywhere in a type-safe way with only minor code duplication.
### Creating a "Stub" Task on your External Service (Recommended)
@@ -30,7 +31,7 @@ Consider a task with an implementation like this:
<Snippet src={snippets.python.stubs.implementation.all} />
To trigger this task from a separate service, for instance, in a microservices architecture, where the code is not shared, start by defining models that match the input and output types of the task defined above.
To trigger this task from a separate service where the code is not shared, start by defining models that match the input and output types of the task defined above.
<Snippet src={snippets.python.stubs.stub_trigger.define_models} />