Skip to content

Commit

Permalink
chore: use channel directions where possible (#299)
Browse files Browse the repository at this point in the history
  • Loading branch information
linxside authored Nov 12, 2023
1 parent 0099bb8 commit 97e1f7e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions internal/pkg/powerdnsutils/powerdnsutils_dnsquery.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func GetZoneFilePerAXFR(address, zoneid string, readtimeout time.Duration) (stri
func doZoneTransfer(zoneid string, address string, readtimeout time.Duration) (zonefile string, err error) {
var conn net.Conn

var channel chan *dns.Envelope
var channel <-chan *dns.Envelope

var d net.Dialer

Expand All @@ -42,7 +42,7 @@ func doZoneTransfer(zoneid string, address string, readtimeout time.Duration) (z
return
}

func receiveAllRecords(channel chan *dns.Envelope) ([]dns.RR, error) {
func receiveAllRecords(channel <-chan *dns.Envelope) ([]dns.RR, error) {
var answerrr []dns.RR

for envmsg := range channel {
Expand Down
14 changes: 7 additions & 7 deletions pkg/microservice/logger/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import (
"github.com/rs/zerolog/log"
)

var signalchannel chan os.Signal //nolint:gochecknoglobals
var signalChannel chan<- os.Signal //nolint:gochecknoglobals

// InitGlobalLogger set global logging settings.
func InitGlobalLogger(sigchannel chan os.Signal) {
func InitGlobalLogger(sigchannel chan<- os.Signal) {
zerolog.TimeFieldFormat = time.RFC3339Nano
zerolog.SetGlobalLevel(zerolog.InfoLevel)

signalchannel = sigchannel
signalChannel = sigchannel
}

// SetDefaultLogLevel with panic, fatal, error, warn, info, debug
Expand Down Expand Up @@ -82,13 +82,13 @@ func ErrorLog(message string) {
}

func FatalLog(message string) {
signalchannel <- syscall.SIGINT
signalChannel <- syscall.SIGINT

log.Log().Str("level", "fatal").Msg(message)
}

func PanicLog(message string) {
signalchannel <- syscall.SIGINT
signalChannel <- syscall.SIGINT

log.Panic().Msg(message)
}
Expand All @@ -110,13 +110,13 @@ func ErrorErrLog(err error) {
}

func FatalErrLog(err error) {
signalchannel <- syscall.SIGINT
signalChannel <- syscall.SIGINT

log.Log().Str("level", "fatal").Err(err).Msg("")
}

func PanicErrLog(err error) {
signalchannel <- syscall.SIGINT
signalChannel <- syscall.SIGINT

log.Panic().Err(err).Msg("")
}
2 changes: 1 addition & 1 deletion pkg/microservice/servicediscovery/servicediscovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ func (sd *ServiceDiscovery) PutValue(key string, value []byte) error {
return err
}

func (sd *ServiceDiscovery) SubscribeToKey(key string, valuechan chan []byte) {
func (sd *ServiceDiscovery) SubscribeToKey(key string, valuechan chan<- []byte) {
actualIndex := uint64(0)

go func() {
Expand Down

0 comments on commit 97e1f7e

Please sign in to comment.