congqixia cb7f2fa6fd
enhance: Use v2 package name for pkg module (#39990)
Related to #39095

https://go.dev/doc/modules/version-numbers

Update pkg version according to golang dep version convention

---------

Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>
2025-02-22 23:15:58 +08:00

39 lines
813 B
Go

package pulsar
import (
"context"
"github.com/apache/pulsar-client-go/pulsar"
"github.com/milvus-io/milvus/pkg/v2/streaming/walimpls"
"github.com/milvus-io/milvus/pkg/v2/streaming/walimpls/helper"
)
var _ walimpls.OpenerImpls = (*openerImpl)(nil)
// openerImpl is the opener for pulsar wal.
type openerImpl struct {
c pulsar.Client
}
// Open opens a wal instance.
func (o *openerImpl) Open(ctx context.Context, opt *walimpls.OpenOption) (walimpls.WALImpls, error) {
p, err := o.c.CreateProducer(pulsar.ProducerOptions{
// TODO: configurations.
Topic: opt.Channel.Name,
})
if err != nil {
return nil, err
}
return &walImpl{
WALHelper: helper.NewWALHelper(opt),
p: p,
c: o.c,
}, nil
}
// Close closes the opener resources.
func (o *openerImpl) Close() {
o.c.Close()
}