为了账号安全,请及时绑定邮箱和手机立即绑定

Aerospike Golang 多主机示例?

Aerospike Golang 多主机示例?

Go
POPMUISE 2022-11-28 10:29:43
我想在 4 个本地服务器上使用 golang aerospike,我可以使用这样的 PHP 代码连接它#CONFIG FOR AEROSPIKE CONNECTION    $CONF['aerospike_server'] = array(        'hosts' => array(            array(                'addr' => '192.168.7.241',                'port' => 3000            ),            array(                'addr' => '192.168.7.243',                'port' => 3000            ),            array(                'addr' => '192.168.7.244',                'port' => 3000            ),            array(                'addr' => '192.168.7.245',                'port' => 3000            )        )    );$aeroDB = new Aerospike($CONF['aerospike_server']);我如何使用 golang 执行此操作?我正在使用这个https://github.com/aerospike/aerospike-client-go 我也在参考中读到确实有 NewClientWithPolicyAndHost 和 NewHosts 但找不到示例或如何使用它。我正在使用 go 版本 go1.17 linux/amd64
查看完整描述

1 回答

?
慕容森

TA贡献1853条经验 获得超18个赞

假设我正确理解了问题,我确实设法获得了一些意见:


client, err := aero.NewClientWithPolicyAndHost(aero.NewClientPolicy(), aero.NewHost(ip1, port1), aero.NewHost(ip2, port2), aero.NewHost(ip3, port3), aero.NewHost(ip4, port4))

if err != nil {

    log.Fatal(err)

}


查看完整回答
反对 回复 2022-11-28
  • 1 回答
  • 0 关注
  • 78 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号