build: upgrade base dependency
This commit is contained in:
14
vendor/github.com/cyrilix/robocar-base/cli/cli.go
generated
vendored
14
vendor/github.com/cyrilix/robocar-base/cli/cli.go
generated
vendored
@ -5,7 +5,7 @@ import (
|
||||
"fmt"
|
||||
"github.com/cyrilix/robocar-base/service"
|
||||
MQTT "github.com/eclipse/paho.mqtt.golang"
|
||||
"log"
|
||||
"go.uber.org/zap"
|
||||
"os"
|
||||
"os/signal"
|
||||
"strconv"
|
||||
@ -25,7 +25,7 @@ func SetIntDefaultValueFromEnv(value *int, key string, defaultValue int) error {
|
||||
sVal = os.Getenv(key)
|
||||
val, err := strconv.Atoi(sVal)
|
||||
if err != nil {
|
||||
log.Printf("unable to convert string to int: %v", err)
|
||||
zap.S().Errorf("unable to convert string to int: %v", err)
|
||||
return err
|
||||
}
|
||||
*value = val
|
||||
@ -40,7 +40,7 @@ func SetFloat64DefaultValueFromEnv(value *float64, key string, defaultValue floa
|
||||
sVal = os.Getenv(key)
|
||||
val, err := strconv.ParseFloat(sVal, 64)
|
||||
if err != nil {
|
||||
log.Printf("unable to convert string to float: %v", err)
|
||||
zap.S().Errorf("unable to convert string to float: %v", err)
|
||||
return err
|
||||
}
|
||||
*value = val
|
||||
@ -81,7 +81,7 @@ func InitIntFlag(key string, defValue int) int {
|
||||
var value int
|
||||
err := SetIntDefaultValueFromEnv(&value, key, defValue)
|
||||
if err != nil {
|
||||
log.Panicf("invalid int value: %v", err)
|
||||
zap.S().Panicf("invalid int value: %v", err)
|
||||
}
|
||||
return value
|
||||
}
|
||||
@ -90,7 +90,7 @@ func InitFloat64Flag(key string, defValue float64) float64 {
|
||||
var value float64
|
||||
err := SetFloat64DefaultValueFromEnv(&value, key, defValue)
|
||||
if err != nil {
|
||||
log.Panicf("invalid value: %v", err)
|
||||
zap.S().Panicf("invalid value: %v", err)
|
||||
}
|
||||
return value
|
||||
}
|
||||
@ -106,8 +106,8 @@ func Connect(uri, username, password, clientId string) (MQTT.Client, error) {
|
||||
opts.SetDefaultPublishHandler(
|
||||
//define a function for the default message handler
|
||||
func(client MQTT.Client, msg MQTT.Message) {
|
||||
fmt.Printf("TOPIC: %s\n", msg.Topic())
|
||||
fmt.Printf("MSG: %s\n", msg.Payload())
|
||||
zap.S().Infof("TOPIC: %s", msg.Topic())
|
||||
zap.S().Infof("MSG: %s", msg.Payload())
|
||||
})
|
||||
|
||||
//create and start a client using the above ClientOptions
|
||||
|
8
vendor/github.com/cyrilix/robocar-base/service/part.go
generated
vendored
8
vendor/github.com/cyrilix/robocar-base/service/part.go
generated
vendored
@ -3,21 +3,21 @@ package service
|
||||
import (
|
||||
"fmt"
|
||||
mqtt "github.com/eclipse/paho.mqtt.golang"
|
||||
"log"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
func StopService(name string, client mqtt.Client, topics ...string) {
|
||||
log.Printf("Stop %s service", name)
|
||||
zap.S().Infof("Stop %s service", name)
|
||||
token := client.Unsubscribe(topics...)
|
||||
token.Wait()
|
||||
if token.Error() != nil {
|
||||
log.Printf("unable to unsubscribe service: %v", token.Error())
|
||||
zap.S().Errorf("unable to unsubscribe service: %v", token.Error())
|
||||
}
|
||||
client.Disconnect(50)
|
||||
}
|
||||
|
||||
func RegisterCallback(client mqtt.Client, topic string, callback mqtt.MessageHandler) error {
|
||||
log.Printf("Register callback on topic %v", topic)
|
||||
zap.S().Infof("Register callback on topic %v", topic)
|
||||
token := client.Subscribe(topic, 0, callback)
|
||||
token.Wait()
|
||||
if token.Error() != nil {
|
||||
|
8
vendor/github.com/cyrilix/robocar-base/testtools/testtools.go
generated
vendored
8
vendor/github.com/cyrilix/robocar-base/testtools/testtools.go
generated
vendored
@ -3,7 +3,7 @@ package testtools
|
||||
import (
|
||||
mqtt "github.com/eclipse/paho.mqtt.golang"
|
||||
"github.com/golang/protobuf/proto"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
type fakeMessage struct {
|
||||
@ -50,10 +50,10 @@ func NewFakeMessage(topic string, payload []byte) mqtt.Message {
|
||||
}
|
||||
}
|
||||
|
||||
func NewFakeMessageFromProtobuf(topic string, msg proto.Message) mqtt.Message{
|
||||
func NewFakeMessageFromProtobuf(topic string, msg proto.Message) mqtt.Message {
|
||||
payload, err := proto.Marshal(msg)
|
||||
if err != nil {
|
||||
log.Errorf("unable to marshal protobuf message %T: %v", msg, err)
|
||||
if err != nil {
|
||||
zap.S().Errorf("unable to marshal protobuf message %T: %v", msg, err)
|
||||
return nil
|
||||
}
|
||||
return NewFakeMessage(topic, payload)
|
||||
|
Reference in New Issue
Block a user