Apache pulsar/pulsar-client-go 部署安装

pulsar-client-go 部署安装

目前pulsar 官方的 pulsar-client-go 实现采用的是cgo的方式,所以当我们构建 pulsar-client-go 的时候,需要预先构建好 puslar-client-cpp

当我们需要把pulsar-client-go 当作外部依赖库时,执行 go get -u github.com/apache/pulsar/pulsar-client-go/pulsar 会出现如下错误:

../go/src/github.com/apache/pulsar/pulsar-client-go/pulsar/c_consumer.go:112:61: could not determine kind of name for C.initial_position
../go/src/github.com/apache/pulsar/pulsar-client-go/pulsar/c_consumer.go:104:3: could not determine kind of name for C.pulsar_configure_set_negative_ack_redelivery_delay_ms
../go/src/github.com/apache/pulsar/pulsar-client-go/pulsar/c_consumer.go:133:4: could not determine kind of name for C.pulsar_consumer_configuration_set_schema_info
../go/src/github.com/apache/pulsar/pulsar-client-go/pulsar/c_consumer.go:313:2: could not determine kind of name for C.pulsar_consumer_negative_acknowledge
../go/src/github.com/apache/pulsar/pulsar-client-go/pulsar/c_consumer.go:318:2: could not determine kind of name for C.pulsar_consumer_negative_acknowledge_id
../go/src/github.com/apache/pulsar/pulsar-client-go/pulsar/c_consumer.go:112:3: could not determine kind of name for C.pulsar_consumer_set_subscription_initial_position
../go/src/github.com/apache/pulsar/pulsar-client-go/pulsar/c_consumer.go:133:58: could not determine kind of name for C.pulsar_schema_type

由于目前pulsar-client-go是使用cgo进行封装的,所以我们需要预先在本地构建好相应的pulsar-client-cpp,这个时候我们需要来到pulsar-client-cpp的目录下执行如下命令:

cd github.com/apache/pulsar/pulsar-client-cpp
cmake .
make
make install

使用如上方式build好cpp。这个时候我们继续执行:go get -u github.com/apache/pulsar/pulsar-client-go/pulsar

注意:

  1. 在执行go mod tidy之前,确保您的终端能够访问外网,可以使用curl www.google.com进行测试,因为golang.org/x/sys这个package需要通过外网才能够访问到, 否则会出现unknown revision XXX相关的错误。或者使用 goproxy ,有时候需要两者结合使用。

  2. 在使用 go get的时候,需要注意一下go的版本,在1.11之前go get是不支持版本的,也就是我们执行go get命令,默认拉取的是latest的代码。

上述的构建方式是构建了最新版本的pulsar,如果我们想选择指定具体版本的方法进行构建时,需要注意pulsar-client-cpp的版本与pulsar-client-go的版本要保持一致。

如果对Pulsar感兴趣,可通过下列方式参与Pulsar社区:

- Pulsar Slack频道: 
  https://apache-pulsar.slack.com/
  可自行在这里注册:
  https://apache-pulsar.herokuapp.com/

- Pulsar邮件列表: http://pulsar.incubator.apache.org/contact


有关Apache Pulsar项目的更多信息,请访问官网:
http://pulsar.incubator.apache.org/
此外也可关注Twitter帐号@apache_pulsar。

你可能感兴趣的:(Apache pulsar/pulsar-client-go 部署安装)