mirror of
https://gitee.com/johng/gf
synced 2026-06-07 10:22:11 +08:00
完善gkafka示例程序
This commit is contained in:
@ -1,10 +1,10 @@
|
||||
// Copyright 2017 gf Author(https://gitee.com/johng/gf). All Rights Reserved.
|
||||
// Copyright 2018 gf Author(https://gitee.com/johng/gf). All Rights Reserved.
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the MIT License.
|
||||
// If a copy of the MIT was not distributed with this file,
|
||||
// You can obtain one at https://gitee.com/johng/gf.
|
||||
|
||||
// Kafka客户端.
|
||||
// Kafka Client.
|
||||
package gkafka
|
||||
|
||||
import (
|
||||
@ -42,7 +42,7 @@ type Message struct {
|
||||
|
||||
|
||||
// New a kafka client.
|
||||
func New(config *Config) *Client {
|
||||
func NewClient(config *Config) *Client {
|
||||
return &Client {
|
||||
Config : config,
|
||||
}
|
||||
|
||||
@ -12,7 +12,7 @@ func main () {
|
||||
config.Servers = "localhost:9092"
|
||||
config.Topics = "test"
|
||||
|
||||
client := gkafka.New(config)
|
||||
client := gkafka.NewClient(config)
|
||||
defer client.Close()
|
||||
|
||||
for {
|
||||
|
||||
@ -10,7 +10,7 @@ func main () {
|
||||
config.Servers = "localhost:9092"
|
||||
config.Topics = "test"
|
||||
|
||||
client := gkafka.New(config)
|
||||
client := gkafka.NewClient(config)
|
||||
defer client.Close()
|
||||
err := client.SyncSend(&gkafka.Message{Value: []byte("1")})
|
||||
fmt.Println(err)
|
||||
|
||||
Reference in New Issue
Block a user