Skip to content

Commit

Permalink
Mark marshallable fields with yaml and omitempty (#477)
Browse files Browse the repository at this point in the history
  • Loading branch information
boks1971 authored Sep 19, 2023
1 parent dd24d07 commit 0708b5a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions logger/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ package logger
import "sync"

type Config struct {
JSON bool `yaml:"json"`
Level string `yaml:"level"`
JSON bool `yaml:"json,omitempty"`
Level string `yaml:"level,omitempty"`
// true to enable log sampling, where the same log message and level will be throttled.
// we have two layers of sampling
// 1. global sampling - within a second, it will log the first SampleInitial, then every SampleInterval messages.
Expand Down
28 changes: 14 additions & 14 deletions redis/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,21 @@ import (
var ErrNotConfigured = errors.New("Redis is not configured")

type RedisConfig struct {
Address string `yaml:"address"`
Username string `yaml:"username"`
Password string `yaml:"password"`
DB int `yaml:"db"`
UseTLS bool `yaml:"use_tls"`
MasterName string `yaml:"sentinel_master_name"`
SentinelUsername string `yaml:"sentinel_username"`
SentinelPassword string `yaml:"sentinel_password"`
SentinelAddresses []string `yaml:"sentinel_addresses"`
ClusterAddresses []string `yaml:"cluster_addresses"`
DialTimeout int `yaml:"dial_timeout"`
ReadTimeout int `yaml:"read_timeout"`
WriteTimeout int `yaml:"write_timeout"`
Address string `yaml:"address,omitempty"`
Username string `yaml:"username,omitempty"`
Password string `yaml:"password,omitempty"`
DB int `yaml:"db,omitempty"`
UseTLS bool `yaml:"use_tls,omitempty"`
MasterName string `yaml:"sentinel_master_name,omitempty"`
SentinelUsername string `yaml:"sentinel_username,omitempty"`
SentinelPassword string `yaml:"sentinel_password,omitempty"`
SentinelAddresses []string `yaml:"sentinel_addresses,omitempty"`
ClusterAddresses []string `yaml:"cluster_addresses,omitempty"`
DialTimeout int `yaml:"dial_timeout,omitempty"`
ReadTimeout int `yaml:"read_timeout,omitempty"`
WriteTimeout int `yaml:"write_timeout,omitempty"`
// for clustererd mode only, number of redirects to follow, defaults to 2
MaxRedirects *int `yaml:"max_redirects"`
MaxRedirects *int `yaml:"max_redirects,omitempty"`
}

func (r *RedisConfig) IsConfigured() bool {
Expand Down

0 comments on commit 0708b5a

Please sign in to comment.