apache / apache/pulsar

[Go Functions] NewOutputMessage API should probably be changed to Publish()

Open
#9,512 1 comment 1 reaction 0 assignees View on GitHub
type/enhancement
Dominant language
Java
Stars
15.3k
Forks
3.8k
Avg merge
1d 22h
Merged PRs (30d)
142

Description

The multi-dispatch functionality in Go Functions (as implemented with `NewOuputMessage()` in #8327) is a bit of an awkward API to use. For one, it returns a new Producer, not a new `OutputMessage` (in fact, the Go SDK does not have the concept of the message builder that is present in Java). For another, no customization of the producer is possible, so it seems unnecessary to have it returned at all. I propose something like the Python SDK, allowing payload to be sent on an arbitrary topic, in conjunction with the caching of producers described in #9511. I think two methods would be most useful:

```go
func (c *FunctionContext) Publish(topicName string, payload []byte) (pulsar.MessageID, error)
func (c *FunctionContext) PublishMessage(topicName string, message *pulsar.ProducerMessage) (pulsar.MessageID, error)
```

Contributor guide

Open the contributing guide

Research direction

Start by reading the Go Functions multi-dispatch implementation described in #8327 and the producer-caching proposal in #9511, then compare the relevant behavior with the Python SDK. The issue needs an agreed API design before implementation can be considered complete; no source files or tests are identified here.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
api, backend-api-design
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.