pulsar-golisted
Install: claude install-skill omeyang/Thoth
# Go Pulsar 专家
使用 Go pulsar-client-go 开发消息队列功能:$ARGUMENTS
---
## 1. 客户端管理
### 创建客户端
```go
func NewPulsarClient(serviceURL string) (pulsar.Client, error)
```
- 配置:OperationTimeout=30s, ConnectionTimeout=10s, MaxConnectionsPerBroker=5
- 可选认证:`pulsar.NewAuthenticationToken("token")`
### 包装器模式
```go
type Pulsar struct { client pulsar.Client }
func New(client pulsar.Client) *Pulsar
func (p *Pulsar) Client() pulsar.Client
func (p *Pulsar) Close()
```
> 完整实现见 [references/examples.md](references/examples.md#1-客户端管理)
---
## 2. 生产者
### 创建生产者
```go
func (p *Pulsar) CreateProducer(topic string) (pulsar.Producer, error)
```
- 批量发送:BatchingMaxPublishDelay=10ms, BatchingMaxMessages=1000
- 压缩:LZ4
- 分区路由:按 Key 哈希路由到固定分区
### 发送消息
| 方法 | 签名 | 说明 |
|------|------|------|
| 同步 | `Send(ctx, producer, msg) (MessageID, error)` | 等待确认 |
| 异步 | `SendAsync(ctx, producer, msg, callback)` | 回调通知 |
| 批量 | `SendBatch(ctx, producer, messages) error` | 并发异步+WaitGroup |
### 延迟消息
```go
// 延迟投递
producer.Send(ctx, &pulsar.ProducerMessage{Payload: data, DeliverAfter: 5 * time.Minute})
// 定时投递
producer.Send(ctx, &pulsar.ProducerMessage{Payload: data, DeliverAt: targetTime})
```
> 完整实现见 [references/examples.md](references/examples.md#2-生产者)
---
## 3. 消费者
### 订阅模式
| 模式 | 函数 | 特点 |
|------|------|------|
| Exclusive | `SubscribeExclusive()` | 独占,只有一个消费者 |
| Shared | `SubscribeShared()` | 共享,多消费者轮询 |
| Failover | `SubscribeFailover()` | 故障转移 |
| KeyShared | `SubscribeKeyShared()` | 按 Key 分区,保证同