원클릭으로
add-outbound-event
TRIGGER when user asks to fire, emit, or publish an event that other microservices can subscribe to.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
TRIGGER when user asks to fire, emit, or publish an event that other microservices can subscribe to.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
TRIGGER when the user asks to upgrade the project to a newer or the latest version of Microbus, or to update the framework. Each Microbus release ships this one self-contained skill; it applies that release's single-version migration, then chains to the next release's copy of this skill until the target version is reached.
TRIGGER when user asks to create, scaffold, or initialize a new microservice.
How to choose the hostname of a new Microbus microservice. Referenced by the add-microservice and add-sql-microservice scaffolding skills (and, through their delegation to add-microservice, by add-python-microservice and import-openapi-microservice). Consult it whenever a microservice's hostname is being chosen.
Performs an architectural review of a microservice-based system built on the Microbus framework. Covers only cross-cutting, cross-microservice concerns - service boundaries, the dependency graph, coupling, cross-service consistency, data ownership, workflow composition, edge security, and system operations. Anything judgeable inside a single microservice directory belongs to the review-microservice skill and is out of scope here. Produces a structured report with findings and recommendations.
Reviews the microservices touched by a set of changes - by default the whole current feature branch versus its merge-base with main, plus any uncommitted work. Runs the review-microservice skill on each changed microservice and the review-architecture skill scoped to those microservices and their graph neighbors, then consolidates one report. Use before merging a branch or before committing working-tree changes.
Performs a thorough review of a single Microbus microservice. Checks for completeness, framework compliance, code quality, security, test coverage, documentation, API design, and data access performance. Produces a structured report with findings and recommendations.
| name | add-outbound-event |
| description | TRIGGER when user asks to fire, emit, or publish an event that other microservices can subscribe to. |
CRITICAL: Do NOT explore or analyze other microservices unless explicitly instructed to do so. The instructions in this skill are self-contained to this microservice.
CRITICAL: An outbound event is declared as a define.OutboundEvent var in myserviceapi/definition.go. Add the declaration and run cmd/genservice. An outbound event has no handler in service.go - this microservice fires it; other microservices sink it.
CRITICAL: Keep the // MARKER: OnMyEvent comment on the define.OutboundEvent var and on its In/Out structs.
IMPORTANT: Outbound events are not exposed via OpenAPI. The connector's built-in :888/openapi.json handler filters them out automatically.
Copy this checklist and track your progress:
Creating or modifying an outbound event:
- [ ] Step 1: Read local CLAUDE.md file
- [ ] Step 2: Determine the signature
- [ ] Step 3: Determine the method and route
- [ ] Step 4: Determine a description
- [ ] Step 5: Define complex types
- [ ] Step 6: Declare the event in definition.go
- [ ] Step 7: Generate the boilerplate
- [ ] Step 8: Trigger the event
- [ ] Step 9: Test the outgoing event
- [ ] Step 10: Housekeeping
CLAUDE.md FileRead the local CLAUDE.md file in the microservice's directory. It contains microservice-specific instructions that should take precedence over global instructions.
Determine the Go signature of the outgoing event.
func OnMyEvent(ctx context.Context, input1 string, input2 ThirdPartyStruct) (output1 map[string]MyStruct, err error)
Constraints:
ctx context.Contexterr errormap[string]anyMyStruct or *MyStructt or svcOn followed by an uppercase letterThe method of the endpoint determines the HTTP method with which it will be addressable. The most common approach is to use POST.
The route of the endpoint is resolved relative to the hostname of the microservice to determine how it is addressed. The common approach is to use the name of the endpoint in kebab-case as its route, e.g. /my-event.
Events should be set on a dedicated port to allow blocking external requests from reaching them. The recommended port to use for events is 417. Prefix the route with the port, e.g. :417/on-my-event.
Do not use path arguments in events.
Prefix the route with // to set a hostname other than that of this microservice, e.g. //another.host.name:417/on-something
Describe the event starting with its name, in Go doc style: OnMyEvent is triggered when X. This becomes the godoc comment on the define.OutboundEvent var.
Identify the struct types in the signature. Define these complex types in the myserviceapi directory. Skip this step if there are no complex types.
Place each definition in a separate file named after the type, e.g. myserviceapi/mystruct.go.
If the complex type is owned by this microservice, define its struct explicitly. Include json tags with camelCase names and the omitzero option, and a short jsonschema description tag on each field.
package myserviceapi
// MyStruct is X.
type MyStruct struct {
FooField string `json:"fooField,omitzero" jsonschema_description:"FooField is X"`
BarField int `json:"barField,omitzero" jsonschema_description:"BarField is X"`
}
If the complex type is owned by another microservice, define an alias to it instead.
package myserviceapi
import (
"github.com/path/to/thirdparty"
)
// ThirdPartyStruct is X.
type ThirdPartyStruct = thirdparty.ThirdPartyStruct
definition.goAppend the define.OutboundEvent var and its In/Out structs to myserviceapi/definition.go.
/*
OnMyEvent is triggered when X.
*/
var OnMyEvent = define.OutboundEvent{ // MARKER: OnMyEvent
Host: Hostname, Method: "POST", Route: ":417/on-my-event",
In: OnMyEventIn{}, Out: OnMyEventOut{},
}
// OnMyEventIn are the input arguments of OnMyEvent.
type OnMyEventIn struct { // MARKER: OnMyEvent
Input1 string `json:"input1,omitzero"`
Input2 ThirdPartyStruct `json:"input2,omitzero"`
}
// OnMyEventOut are the output arguments of OnMyEvent.
type OnMyEventOut struct { // MARKER: OnMyEvent
Output1 map[string]MyStruct `json:"output1,omitzero"`
}
Host is always Hostname. Method and Route come from Step 3ctx; the Out struct holds the output arguments excluding errtime.Time field needs "time"), add that import to definition.goFrom the microservice's directory, run the generator. It regenerates myserviceapi/client.go (the MulticastTrigger, the Hook, and the response wrapper for OnMyEvent) and manifest.yaml from the updated definition.go. It also scaffolds a placeholder test in service_test.go for the event, ready for you to fill in.
go run github.com/microbus-io/fabric/cmd/genservice .
Then verify the microservice compiles with go vet ./... from the project root.
The event has no implementation of its own. Trigger it from within other endpoints using the generated trigger.
To fire an event and wait for zero or more responses, loop over the response sequence.
for r := range myserviceapi.NewMulticastTrigger(svc).OnMyEvent(ctx, input1, input2) {
output1, err := r.Get()
if err != nil {
return errors.Trace(err)
}
// ...
}
To fire and forget, call the trigger without iterating over its response.
myserviceapi.NewMulticastTrigger(svc).OnMyEvent(ctx, input1, input2)
Skip this step if instructed to be "quick" or to skip tests.
The boilerplate generator created a placeholder test function TestMyService_OnMyEvent in service_test.go, tagged with a // MARKER: OnMyEvent comment and a HINT block. Add one or more test cases at the bottom of that function, following the pattern shown in its HINT comment. Do not remove the HINT comment.
Follow the housekeeping skill.