Skip to content

feat(v3): per-operation function name overrides (#162) - #327

Merged
lerenn merged 1 commit into
mainfrom
feat/162-func-name-overrides
Jun 12, 2026
Merged

lerenn merged 1 commit into
mainfrom
feat/162-func-name-overrides

Conversation

@lerenn

@lerenn lerenn commented Jun 12, 2026

Copy link
Copy Markdown
Owner

Issue

Fixes #162 — there was no way to override the Go names of the functions generated for an operation; they were always derived from the operation name.

Change

Adds five operation-level extensions (AsyncAPI v3) that each override one generated function name:

Extension Overrides
x-go-subscribe-func SubscribeTo<Op>
x-go-received-func <Op>Received subscriber callback
x-go-reply-func ReplyTo<Op>
x-go-send-func Send{As,To}<Op>
x-go-request-func Request{As,To}<Op>

Each name is resolved through a template helper that returns the override (when set) or the exact previous default. Definitions, all call sites, and doc comments route through the helpers — including the internal reply-sender call, which resolves via the receive operation's ReplyIs so request/reply cross-references stay consistent. Because the defaults are unchanged, go generate ./... produces no diff in existing golden files or examples.

Test

test/v3/issues/162 defines a request-reply ping operation carrying all five extensions. The suite implements the generated AppSubscriber via OnPing and references ListenForPing / AnswerPing / PublishPing / AskPing as method expressions — it fails to compile before the change (those names don't exist) and passes after.

🤖 Generated with Claude Code

Add x-go-send-func, x-go-subscribe-func, x-go-received-func,
x-go-reply-func and x-go-request-func operation extensions that override
the Go names of the generated Subscribe/Received/Reply/Send/Request
functions. When unset, the default derived names are used, so existing
generated code is unchanged.

Fixes #162

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@lerenn
lerenn force-pushed the feat/162-func-name-overrides branch from e0adf9d to ad19b46 Compare June 12, 2026 15:34
@lerenn
lerenn merged commit af37d74 into main Jun 12, 2026
5 checks passed
@lerenn
lerenn deleted the feat/162-func-name-overrides branch June 12, 2026 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add overwritable function name based on side

1 participant