Documentation ¶
Index ¶
- func AdjustDuration(v *time.Duration, defValue time.Duration)
- func AdjustInt(v *int, defValue int)
- func AdjustString(v *string, defValue string)
- func DefaultIP() (ip string, err error)
- func DefaultListenAddr(port int32) string
- func GenFakeBinlog(ts int64) *binlog.Binlog
- func GetApproachTS(ts int64, tm time.Time) int64
- func GetParentMetricsRegistry() metrics.Registry
- func GetPdClient(etcdURLs string, securityConfig security.Config) (pd.Client, error)
- func GetTSO(pdCli pd.Client) (int64, error)
- func InitLogger(level string, file string) error
- func IsCreateDatabaseDDL(sql string, sqlMode mysql.SQLMode) bool
- func IsValidateListenHost(host string) bool
- func Listen(network, addr string, tlsConfig *tls.Config) (listener net.Listener, err error)
- func NewSaramaConfig(kafkaVersion string, metricsPrefix string) (*sarama.Config, error)
- func QueryLatestTsFromPD(tiStore kv.Storage) (int64, error)
- func RetryContext(ctx context.Context, retryCount int, sleepTime time.Duration, ...) error
- func RetryOnError(retryCount int, sleepTime time.Duration, errStr string, fn func() error) error
- func SetupSignalHandler(shudownFunc func(sig os.Signal))
- func StrictDecodeFile(path, component string, cfg interface{}) error
- func TSOToRoughTime(ts int64) time.Time
- func ToColumnMap(columns []*model.ColumnInfo) map[int64]*model.ColumnInfo
- func ToColumnTypeMap(columns []*model.ColumnInfo) map[int64]*types.FieldType
- func TryUntilSuccess(ctx context.Context, waitInterval time.Duration, errMsg string, ...) error
- func WaitUntilTimeout(name string, fn func(), timeout time.Duration)
- func WriteFileAtomic(filename string, data []byte, perm os.FileMode) error
- type Duration
- type Log
- type LogHook
- type MetricClient
- type Response
- type StdLogger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AdjustDuration ¶
AdjustDuration adjusts v to default value if v is nil
func AdjustString ¶
AdjustString adjusts v to default value if v is nil
func DefaultListenAddr ¶
DefaultListenAddr returns default listen address with appointed port.
func GenFakeBinlog ¶
func GenFakeBinlog(ts int64) *binlog.Binlog
GenFakeBinlog generates a fake binlog from given tso
func GetApproachTS ¶
GetApproachTS get a approach ts by ts and time
func GetParentMetricsRegistry ¶
GetParentMetricsRegistry get the metrics registry and expose the metrics while /debug/metrics
func GetPdClient ¶
GetPdClient create a PD client
func IsCreateDatabaseDDL ¶
IsCreateDatabaseDDL checks whether ddl is a create database statement
func IsValidateListenHost ¶
IsValidateListenHost judge the host is validate listen host or not.
func NewSaramaConfig ¶
NewSaramaConfig return the default config and set the according version and metrics
func QueryLatestTsFromPD ¶
QueryLatestTsFromPD returns the latest ts
func RetryContext ¶
func RetryContext(ctx context.Context, retryCount int, sleepTime time.Duration, backoffFactor int, fn func(context.Context) error) error
RetryContext retries the specified `fn` until it returns no error or the context is canceled, for at most `retryCount` times. The wait time before the `i`th retry is calculated with `sleepTime` * (`backoffFactor` ** i).
func RetryOnError ¶
RetryOnError defines a action with retry when fn returns error
func SetupSignalHandler ¶
SetupSignalHandler setup signal handler
func StrictDecodeFile ¶
StrictDecodeFile decodes the toml file strictly. If any item in confFile file is not mapped into the Config struct, issue an error and stop the server from starting.
func TSOToRoughTime ¶
TSOToRoughTime translates tso to rough time that used to display
func ToColumnMap ¶
func ToColumnMap(columns []*model.ColumnInfo) map[int64]*model.ColumnInfo
ToColumnMap return a map index by column id
func ToColumnTypeMap ¶
func ToColumnTypeMap(columns []*model.ColumnInfo) map[int64]*types.FieldType
ToColumnTypeMap return a map index by column id
func TryUntilSuccess ¶
func TryUntilSuccess(ctx context.Context, waitInterval time.Duration, errMsg string, fn func() error) error
TryUntilSuccess retries the given function until error is nil or the context is done, waiting for `waitInterval` time between retries.
func WaitUntilTimeout ¶
WaitUntilTimeout creates a goroutine to run fn, and then gives up waiting for the goroutine to exit When it timeouts
Types ¶
type Duration ¶
type Duration string
Duration is a wrapper of time.Duration for TOML and JSON. it can be parsed to both integer and string integer 7 will be parsed to 7*24h string 10m will be parsed to 10m
func NewDuration ¶
NewDuration creates a Duration from time.Duration.
func (Duration) MarshalJSON ¶
MarshalJSON returns the duration as a JSON string.
func (Duration) MarshalText ¶
MarshalText returns the duration as a JSON string.
func (Duration) ParseDuration ¶
ParseDuration parses gc durations. The default unit is day.
func (*Duration) UnmarshalJSON ¶
UnmarshalJSON parses a JSON string into the duration.
func (*Duration) UnmarshalText ¶
UnmarshalText parses a TOML string into the duration.
type LogHook ¶
type LogHook struct { // save the log entrys Entrys []zapcore.Entry // contains filtered or unexported fields }
LogHook to get the save entrys for test
type MetricClient ¶
type MetricClient struct {
// contains filtered or unexported fields
}
MetricClient manage the periodic push to the Prometheus Pushgateway.
func NewMetricClient ¶
func NewMetricClient(addr string, interval time.Duration, registry *prometheus.Registry) *MetricClient
NewMetricClient returns a pointer to a MetricClient
type Response ¶
type Response struct { Message string `json:"message"` Code int `json:"code"` Data interface{} `json:"data"` }
Response represents message that returns to client
func ErrResponsef ¶
ErrResponsef returns a error response.
func NotFoundResponsef ¶
NotFoundResponsef returns a not found response.
func SuccessResponse ¶
SuccessResponse returns a success response.
type StdLogger ¶
type StdLogger struct {
// contains filtered or unexported fields
}
StdLogger implements samara.StdLogger
func NewStdLogger ¶
NewStdLogger return an instance of StdLogger
func (StdLogger) Print ¶
func (l StdLogger) Print(v ...interface{})
Print implements samara.StdLogger