MM-34932: Bump dependencies (#17708)
https://mattermost.atlassian.net/browse/MM-34932 ```release-note NONE ```
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
fff09bf210
Коммит
3299a72adb
72
vendor/github.com/hashicorp/go-hclog/interceptlogger.go
сгенерированный
поставляемый
72
vendor/github.com/hashicorp/go-hclog/interceptlogger.go
сгенерированный
поставляемый
@@ -18,8 +18,13 @@ type interceptLogger struct {
|
||||
}
|
||||
|
||||
func NewInterceptLogger(opts *LoggerOptions) InterceptLogger {
|
||||
l := newLogger(opts)
|
||||
if l.callerOffset > 0 {
|
||||
// extra frames for interceptLogger.{Warn,Info,Log,etc...}, and interceptLogger.log
|
||||
l.callerOffset += 2
|
||||
}
|
||||
intercept := &interceptLogger{
|
||||
Logger: New(opts),
|
||||
Logger: l,
|
||||
mu: new(sync.Mutex),
|
||||
sinkCount: new(int32),
|
||||
Sinks: make(map[SinkAdapter]struct{}),
|
||||
@@ -31,6 +36,14 @@ func NewInterceptLogger(opts *LoggerOptions) InterceptLogger {
|
||||
}
|
||||
|
||||
func (i *interceptLogger) Log(level Level, msg string, args ...interface{}) {
|
||||
i.log(level, msg, args...)
|
||||
}
|
||||
|
||||
// log is used to make the caller stack frame lookup consistent. If Warn,Info,etc
|
||||
// all called Log then direct calls to Log would have a different stack frame
|
||||
// depth. By having all the methods call the same helper we ensure the stack
|
||||
// frame depth is the same.
|
||||
func (i *interceptLogger) log(level Level, msg string, args ...interface{}) {
|
||||
i.Logger.Log(level, msg, args...)
|
||||
if atomic.LoadInt32(i.sinkCount) == 0 {
|
||||
return
|
||||
@@ -45,72 +58,27 @@ func (i *interceptLogger) Log(level Level, msg string, args ...interface{}) {
|
||||
|
||||
// Emit the message and args at TRACE level to log and sinks
|
||||
func (i *interceptLogger) Trace(msg string, args ...interface{}) {
|
||||
i.Logger.Trace(msg, args...)
|
||||
if atomic.LoadInt32(i.sinkCount) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
i.mu.Lock()
|
||||
defer i.mu.Unlock()
|
||||
for s := range i.Sinks {
|
||||
s.Accept(i.Name(), Trace, msg, i.retrieveImplied(args...)...)
|
||||
}
|
||||
i.log(Trace, msg, args...)
|
||||
}
|
||||
|
||||
// Emit the message and args at DEBUG level to log and sinks
|
||||
func (i *interceptLogger) Debug(msg string, args ...interface{}) {
|
||||
i.Logger.Debug(msg, args...)
|
||||
if atomic.LoadInt32(i.sinkCount) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
i.mu.Lock()
|
||||
defer i.mu.Unlock()
|
||||
for s := range i.Sinks {
|
||||
s.Accept(i.Name(), Debug, msg, i.retrieveImplied(args...)...)
|
||||
}
|
||||
i.log(Debug, msg, args...)
|
||||
}
|
||||
|
||||
// Emit the message and args at INFO level to log and sinks
|
||||
func (i *interceptLogger) Info(msg string, args ...interface{}) {
|
||||
i.Logger.Info(msg, args...)
|
||||
if atomic.LoadInt32(i.sinkCount) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
i.mu.Lock()
|
||||
defer i.mu.Unlock()
|
||||
for s := range i.Sinks {
|
||||
s.Accept(i.Name(), Info, msg, i.retrieveImplied(args...)...)
|
||||
}
|
||||
i.log(Info, msg, args...)
|
||||
}
|
||||
|
||||
// Emit the message and args at WARN level to log and sinks
|
||||
func (i *interceptLogger) Warn(msg string, args ...interface{}) {
|
||||
i.Logger.Warn(msg, args...)
|
||||
if atomic.LoadInt32(i.sinkCount) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
i.mu.Lock()
|
||||
defer i.mu.Unlock()
|
||||
for s := range i.Sinks {
|
||||
s.Accept(i.Name(), Warn, msg, i.retrieveImplied(args...)...)
|
||||
}
|
||||
i.log(Warn, msg, args...)
|
||||
}
|
||||
|
||||
// Emit the message and args at ERROR level to log and sinks
|
||||
func (i *interceptLogger) Error(msg string, args ...interface{}) {
|
||||
i.Logger.Error(msg, args...)
|
||||
if atomic.LoadInt32(i.sinkCount) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
i.mu.Lock()
|
||||
defer i.mu.Unlock()
|
||||
for s := range i.Sinks {
|
||||
s.Accept(i.Name(), Error, msg, i.retrieveImplied(args...)...)
|
||||
}
|
||||
i.log(Error, msg, args...)
|
||||
}
|
||||
|
||||
func (i *interceptLogger) retrieveImplied(args ...interface{}) []interface{} {
|
||||
@@ -123,7 +91,7 @@ func (i *interceptLogger) retrieveImplied(args ...interface{}) []interface{} {
|
||||
return cp
|
||||
}
|
||||
|
||||
// Create a new sub-Logger that a name decending from the current name.
|
||||
// Create a new sub-Logger that a name descending from the current name.
|
||||
// This is used to create a subsystem specific Logger.
|
||||
// Registered sinks will subscribe to these messages as well.
|
||||
func (i *interceptLogger) Named(name string) Logger {
|
||||
|
||||
136
vendor/github.com/hashicorp/go-hclog/intlogger.go
сгенерированный
поставляемый
136
vendor/github.com/hashicorp/go-hclog/intlogger.go
сгенерированный
поставляемый
@@ -21,10 +21,14 @@ import (
|
||||
"github.com/fatih/color"
|
||||
)
|
||||
|
||||
// TimeFormat to use for logging. This is a version of RFC3339 that contains
|
||||
// contains millisecond precision
|
||||
// TimeFormat is the time format to use for plain (non-JSON) output.
|
||||
// This is a version of RFC3339 that contains millisecond precision.
|
||||
const TimeFormat = "2006-01-02T15:04:05.000Z0700"
|
||||
|
||||
// TimeFormatJSON is the time format to use for JSON output.
|
||||
// This is a version of RFC3339 that contains microsecond precision.
|
||||
const TimeFormatJSON = "2006-01-02T15:04:05.000000Z07:00"
|
||||
|
||||
// errJsonUnsupportedTypeMsg is included in log json entries, if an arg cannot be serialized to json
|
||||
const errJsonUnsupportedTypeMsg = "logging contained values that don't serialize to json"
|
||||
|
||||
@@ -52,10 +56,11 @@ var _ Logger = &intLogger{}
|
||||
// intLogger is an internal logger implementation. Internal in that it is
|
||||
// defined entirely by this package.
|
||||
type intLogger struct {
|
||||
json bool
|
||||
caller bool
|
||||
name string
|
||||
timeFormat string
|
||||
json bool
|
||||
callerOffset int
|
||||
name string
|
||||
timeFormat string
|
||||
disableTime bool
|
||||
|
||||
// This is an interface so that it's shared by any derived loggers, since
|
||||
// those derived loggers share the bufio.Writer as well.
|
||||
@@ -79,7 +84,12 @@ func New(opts *LoggerOptions) Logger {
|
||||
// NewSinkAdapter returns a SinkAdapter with configured settings
|
||||
// defined by LoggerOptions
|
||||
func NewSinkAdapter(opts *LoggerOptions) SinkAdapter {
|
||||
return newLogger(opts)
|
||||
l := newLogger(opts)
|
||||
if l.callerOffset > 0 {
|
||||
// extra frames for interceptLogger.{Warn,Info,Log,etc...}, and SinkAdapter.Accept
|
||||
l.callerOffset += 2
|
||||
}
|
||||
return l
|
||||
}
|
||||
|
||||
func newLogger(opts *LoggerOptions) *intLogger {
|
||||
@@ -104,29 +114,37 @@ func newLogger(opts *LoggerOptions) *intLogger {
|
||||
|
||||
l := &intLogger{
|
||||
json: opts.JSONFormat,
|
||||
caller: opts.IncludeLocation,
|
||||
name: opts.Name,
|
||||
timeFormat: TimeFormat,
|
||||
disableTime: opts.DisableTime,
|
||||
mutex: mutex,
|
||||
writer: newWriter(output, opts.Color),
|
||||
level: new(int32),
|
||||
exclude: opts.Exclude,
|
||||
independentLevels: opts.IndependentLevels,
|
||||
}
|
||||
if opts.IncludeLocation {
|
||||
l.callerOffset = offsetIntLogger + opts.AdditionalLocationOffset
|
||||
}
|
||||
|
||||
l.setColorization(opts)
|
||||
|
||||
if opts.DisableTime {
|
||||
l.timeFormat = ""
|
||||
} else if opts.TimeFormat != "" {
|
||||
if l.json {
|
||||
l.timeFormat = TimeFormatJSON
|
||||
}
|
||||
if opts.TimeFormat != "" {
|
||||
l.timeFormat = opts.TimeFormat
|
||||
}
|
||||
|
||||
l.setColorization(opts)
|
||||
|
||||
atomic.StoreInt32(l.level, int32(level))
|
||||
|
||||
return l
|
||||
}
|
||||
|
||||
// offsetIntLogger is the stack frame offset in the call stack for the caller to
|
||||
// one of the Warn,Info,Log,etc methods.
|
||||
const offsetIntLogger = 3
|
||||
|
||||
// Log a message and a set of key/value pairs if the given level is at
|
||||
// or more severe that the threshold configured in the Logger.
|
||||
func (l *intLogger) log(name string, level Level, msg string, args ...interface{}) {
|
||||
@@ -183,7 +201,8 @@ func trimCallerPath(path string) string {
|
||||
|
||||
// Non-JSON logging format function
|
||||
func (l *intLogger) logPlain(t time.Time, name string, level Level, msg string, args ...interface{}) {
|
||||
if len(l.timeFormat) > 0 {
|
||||
|
||||
if !l.disableTime {
|
||||
l.writer.WriteString(t.Format(l.timeFormat))
|
||||
l.writer.WriteByte(' ')
|
||||
}
|
||||
@@ -195,17 +214,8 @@ func (l *intLogger) logPlain(t time.Time, name string, level Level, msg string,
|
||||
l.writer.WriteString("[?????]")
|
||||
}
|
||||
|
||||
offset := 3
|
||||
if l.caller {
|
||||
// Check if the caller is inside our package and inside
|
||||
// a logger implementation file
|
||||
if _, file, _, ok := runtime.Caller(3); ok {
|
||||
if strings.HasSuffix(file, "intlogger.go") || strings.HasSuffix(file, "interceptlogger.go") {
|
||||
offset = 4
|
||||
}
|
||||
}
|
||||
|
||||
if _, file, line, ok := runtime.Caller(offset); ok {
|
||||
if l.callerOffset > 0 {
|
||||
if _, file, line, ok := runtime.Caller(l.callerOffset); ok {
|
||||
l.writer.WriteByte(' ')
|
||||
l.writer.WriteString(trimCallerPath(file))
|
||||
l.writer.WriteByte(':')
|
||||
@@ -251,6 +261,9 @@ func (l *intLogger) logPlain(t time.Time, name string, level Level, msg string,
|
||||
switch st := args[i+1].(type) {
|
||||
case string:
|
||||
val = st
|
||||
if st == "" {
|
||||
val = `""`
|
||||
}
|
||||
case int:
|
||||
val = strconv.FormatInt(int64(st), 10)
|
||||
case int64:
|
||||
@@ -292,20 +305,32 @@ func (l *intLogger) logPlain(t time.Time, name string, level Level, msg string,
|
||||
}
|
||||
}
|
||||
|
||||
l.writer.WriteByte(' ')
|
||||
var key string
|
||||
|
||||
switch st := args[i].(type) {
|
||||
case string:
|
||||
l.writer.WriteString(st)
|
||||
key = st
|
||||
default:
|
||||
l.writer.WriteString(fmt.Sprintf("%s", st))
|
||||
key = fmt.Sprintf("%s", st)
|
||||
}
|
||||
l.writer.WriteByte('=')
|
||||
|
||||
if !raw && strings.ContainsAny(val, " \t\n\r") {
|
||||
if strings.Contains(val, "\n") {
|
||||
l.writer.WriteString("\n ")
|
||||
l.writer.WriteString(key)
|
||||
l.writer.WriteString("=\n")
|
||||
writeIndent(l.writer, val, " | ")
|
||||
l.writer.WriteString(" ")
|
||||
} else if !raw && strings.ContainsAny(val, " \t") {
|
||||
l.writer.WriteByte(' ')
|
||||
l.writer.WriteString(key)
|
||||
l.writer.WriteByte('=')
|
||||
l.writer.WriteByte('"')
|
||||
l.writer.WriteString(val)
|
||||
l.writer.WriteByte('"')
|
||||
} else {
|
||||
l.writer.WriteByte(' ')
|
||||
l.writer.WriteString(key)
|
||||
l.writer.WriteByte('=')
|
||||
l.writer.WriteString(val)
|
||||
}
|
||||
}
|
||||
@@ -319,6 +344,25 @@ func (l *intLogger) logPlain(t time.Time, name string, level Level, msg string,
|
||||
}
|
||||
}
|
||||
|
||||
func writeIndent(w *writer, str string, indent string) {
|
||||
for {
|
||||
nl := strings.IndexByte(str, "\n"[0])
|
||||
if nl == -1 {
|
||||
if str != "" {
|
||||
w.WriteString(indent)
|
||||
w.WriteString(str)
|
||||
w.WriteString("\n")
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
w.WriteString(indent)
|
||||
w.WriteString(str[:nl])
|
||||
w.WriteString("\n")
|
||||
str = str[nl+1:]
|
||||
}
|
||||
}
|
||||
|
||||
func (l *intLogger) renderSlice(v reflect.Value) string {
|
||||
var buf bytes.Buffer
|
||||
|
||||
@@ -335,22 +379,19 @@ func (l *intLogger) renderSlice(v reflect.Value) string {
|
||||
|
||||
switch sv.Kind() {
|
||||
case reflect.String:
|
||||
val = sv.String()
|
||||
val = strconv.Quote(sv.String())
|
||||
case reflect.Int, reflect.Int16, reflect.Int32, reflect.Int64:
|
||||
val = strconv.FormatInt(sv.Int(), 10)
|
||||
case reflect.Uint, reflect.Uint16, reflect.Uint32, reflect.Uint64:
|
||||
val = strconv.FormatUint(sv.Uint(), 10)
|
||||
default:
|
||||
val = fmt.Sprintf("%v", sv.Interface())
|
||||
if strings.ContainsAny(val, " \t\n\r") {
|
||||
val = strconv.Quote(val)
|
||||
}
|
||||
}
|
||||
|
||||
if strings.ContainsAny(val, " \t\n\r") {
|
||||
buf.WriteByte('"')
|
||||
buf.WriteString(val)
|
||||
buf.WriteByte('"')
|
||||
} else {
|
||||
buf.WriteString(val)
|
||||
}
|
||||
buf.WriteString(val)
|
||||
}
|
||||
|
||||
buf.WriteRune(']')
|
||||
@@ -416,8 +457,10 @@ func (l *intLogger) logJSON(t time.Time, name string, level Level, msg string, a
|
||||
|
||||
func (l intLogger) jsonMapEntry(t time.Time, name string, level Level, msg string) map[string]interface{} {
|
||||
vals := map[string]interface{}{
|
||||
"@message": msg,
|
||||
"@timestamp": t.Format("2006-01-02T15:04:05.000000Z07:00"),
|
||||
"@message": msg,
|
||||
}
|
||||
if !l.disableTime {
|
||||
vals["@timestamp"] = t.Format(l.timeFormat)
|
||||
}
|
||||
|
||||
var levelStr string
|
||||
@@ -442,8 +485,8 @@ func (l intLogger) jsonMapEntry(t time.Time, name string, level Level, msg strin
|
||||
vals["@module"] = name
|
||||
}
|
||||
|
||||
if l.caller {
|
||||
if _, file, line, ok := runtime.Caller(4); ok {
|
||||
if l.callerOffset > 0 {
|
||||
if _, file, line, ok := runtime.Caller(l.callerOffset + 1); ok {
|
||||
vals["@caller"] = fmt.Sprintf("%s:%d", file, line)
|
||||
}
|
||||
}
|
||||
@@ -633,8 +676,15 @@ func (l *intLogger) StandardLogger(opts *StandardLoggerOptions) *log.Logger {
|
||||
}
|
||||
|
||||
func (l *intLogger) StandardWriter(opts *StandardLoggerOptions) io.Writer {
|
||||
newLog := *l
|
||||
if l.callerOffset > 0 {
|
||||
// the stack is
|
||||
// logger.printf() -> l.Output() ->l.out.writer(hclog:stdlogAdaptor.write) -> hclog:stdlogAdaptor.dispatch()
|
||||
// So plus 4.
|
||||
newLog.callerOffset = l.callerOffset + 4
|
||||
}
|
||||
return &stdlogAdapter{
|
||||
log: l,
|
||||
log: &newLog,
|
||||
inferLevels: opts.InferLevels,
|
||||
forceLevel: opts.ForceLevel,
|
||||
}
|
||||
|
||||
4
vendor/github.com/hashicorp/go-hclog/logger.go
сгенерированный
поставляемый
4
vendor/github.com/hashicorp/go-hclog/logger.go
сгенерированный
поставляемый
@@ -235,6 +235,10 @@ type LoggerOptions struct {
|
||||
// Include file and line information in each log line
|
||||
IncludeLocation bool
|
||||
|
||||
// AdditionalLocationOffset is the number of additional stack levels to skip
|
||||
// when finding the file and line information for the log line
|
||||
AdditionalLocationOffset int
|
||||
|
||||
// The time format to use instead of the default
|
||||
TimeFormat string
|
||||
|
||||
|
||||
11
vendor/github.com/hashicorp/go-plugin/client.go
сгенерированный
поставляемый
11
vendor/github.com/hashicorp/go-plugin/client.go
сгенерированный
поставляемый
@@ -209,9 +209,10 @@ type ClientConfig struct {
|
||||
// already-running plugin process. You can retrieve this information by
|
||||
// calling ReattachConfig on Client.
|
||||
type ReattachConfig struct {
|
||||
Protocol Protocol
|
||||
Addr net.Addr
|
||||
Pid int
|
||||
Protocol Protocol
|
||||
ProtocolVersion int
|
||||
Addr net.Addr
|
||||
Pid int
|
||||
|
||||
// Test is set to true if this is reattaching to to a plugin in "test mode"
|
||||
// (see ServeConfig.Test). In this mode, client.Kill will NOT kill the
|
||||
@@ -839,6 +840,10 @@ func (c *Client) reattach() (net.Addr, error) {
|
||||
c.protocol = ProtocolNetRPC
|
||||
}
|
||||
|
||||
if c.config.Reattach.Test {
|
||||
c.negotiatedVersion = c.config.Reattach.ProtocolVersion
|
||||
}
|
||||
|
||||
// If we're in test mode, we do NOT set the process. This avoids the
|
||||
// process being killed (the only purpose we have for c.process), since
|
||||
// in test mode the process is responsible for exiting on its own.
|
||||
|
||||
9
vendor/github.com/hashicorp/go-plugin/server.go
сгенерированный
поставляемый
9
vendor/github.com/hashicorp/go-plugin/server.go
сгенерированный
поставляемый
@@ -415,10 +415,11 @@ func Serve(opts *ServeConfig) {
|
||||
// quite ready if they connect immediately but the client should
|
||||
// retry a few times.
|
||||
ch <- &ReattachConfig{
|
||||
Protocol: protoType,
|
||||
Addr: listener.Addr(),
|
||||
Pid: os.Getpid(),
|
||||
Test: true,
|
||||
Protocol: protoType,
|
||||
ProtocolVersion: protoVersion,
|
||||
Addr: listener.Addr(),
|
||||
Pid: os.Getpid(),
|
||||
Test: true,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
9
vendor/github.com/hashicorp/memberlist/event_delegate.go
сгенерированный
поставляемый
9
vendor/github.com/hashicorp/memberlist/event_delegate.go
сгенерированный
поставляемый
@@ -49,13 +49,16 @@ type NodeEvent struct {
|
||||
}
|
||||
|
||||
func (c *ChannelEventDelegate) NotifyJoin(n *Node) {
|
||||
c.Ch <- NodeEvent{NodeJoin, n}
|
||||
node := *n
|
||||
c.Ch <- NodeEvent{NodeJoin, &node}
|
||||
}
|
||||
|
||||
func (c *ChannelEventDelegate) NotifyLeave(n *Node) {
|
||||
c.Ch <- NodeEvent{NodeLeave, n}
|
||||
node := *n
|
||||
c.Ch <- NodeEvent{NodeLeave, &node}
|
||||
}
|
||||
|
||||
func (c *ChannelEventDelegate) NotifyUpdate(n *Node) {
|
||||
c.Ch <- NodeEvent{NodeUpdate, n}
|
||||
node := *n
|
||||
c.Ch <- NodeEvent{NodeUpdate, &node}
|
||||
}
|
||||
|
||||
4
vendor/github.com/hashicorp/memberlist/net.go
сгенерированный
поставляемый
4
vendor/github.com/hashicorp/memberlist/net.go
сгенерированный
поставляемый
@@ -355,6 +355,10 @@ func (m *Memberlist) ingestPacket(buf []byte, from net.Addr, timestamp time.Time
|
||||
}
|
||||
|
||||
func (m *Memberlist) handleCommand(buf []byte, from net.Addr, timestamp time.Time) {
|
||||
if len(buf) < 1 {
|
||||
m.logger.Printf("[ERR] memberlist: missing message type byte %s", LogAddress(from))
|
||||
return
|
||||
}
|
||||
// Decode the message type
|
||||
msgType := messageType(buf[0])
|
||||
buf = buf[1:]
|
||||
|
||||
13
vendor/github.com/hashicorp/memberlist/state.go
сгенерированный
поставляемый
13
vendor/github.com/hashicorp/memberlist/state.go
сгенерированный
поставляемый
@@ -602,13 +602,13 @@ func (m *Memberlist) gossip() {
|
||||
addr := node.Address()
|
||||
if len(msgs) == 1 {
|
||||
// Send single message as is
|
||||
if err := m.rawSendMsgPacket(node.FullAddress(), &node.Node, msgs[0]); err != nil {
|
||||
if err := m.rawSendMsgPacket(node.FullAddress(), &node, msgs[0]); err != nil {
|
||||
m.logger.Printf("[ERR] memberlist: Failed to send gossip to %s: %s", addr, err)
|
||||
}
|
||||
} else {
|
||||
// Otherwise create and send a compound message
|
||||
compound := makeCompoundMessage(msgs)
|
||||
if err := m.rawSendMsgPacket(node.FullAddress(), &node.Node, compound.Bytes()); err != nil {
|
||||
if err := m.rawSendMsgPacket(node.FullAddress(), &node, compound.Bytes()); err != nil {
|
||||
m.logger.Printf("[ERR] memberlist: Failed to send gossip to %s: %s", addr, err)
|
||||
}
|
||||
}
|
||||
@@ -1198,9 +1198,14 @@ func (m *Memberlist) suspectNode(s *suspect) {
|
||||
min := suspicionTimeout(m.config.SuspicionMult, n, m.config.ProbeInterval)
|
||||
max := time.Duration(m.config.SuspicionMaxTimeoutMult) * min
|
||||
fn := func(numConfirmations int) {
|
||||
var d *dead
|
||||
|
||||
m.nodeLock.Lock()
|
||||
state, ok := m.nodeMap[s.Node]
|
||||
timeout := ok && state.State == StateSuspect && state.StateChange == changeTime
|
||||
if timeout {
|
||||
d = &dead{Incarnation: state.Incarnation, Node: state.Name, From: m.config.Name}
|
||||
}
|
||||
m.nodeLock.Unlock()
|
||||
|
||||
if timeout {
|
||||
@@ -1210,8 +1215,8 @@ func (m *Memberlist) suspectNode(s *suspect) {
|
||||
|
||||
m.logger.Printf("[INFO] memberlist: Marking %s as failed, suspect timeout reached (%d peer confirmations)",
|
||||
state.Name, numConfirmations)
|
||||
d := dead{Incarnation: state.Incarnation, Node: state.Name, From: m.config.Name}
|
||||
m.deadNode(&d)
|
||||
|
||||
m.deadNode(d)
|
||||
}
|
||||
}
|
||||
m.nodeTimers[s.Node] = newSuspicion(s.From, k, min, max, fn)
|
||||
|
||||
26
vendor/github.com/hashicorp/memberlist/transport.go
сгенерированный
поставляемый
26
vendor/github.com/hashicorp/memberlist/transport.go
сгенерированный
поставляемый
@@ -82,16 +82,18 @@ func (a *Address) String() string {
|
||||
return a.Addr
|
||||
}
|
||||
|
||||
// IngestionAwareTransport is not used.
|
||||
//
|
||||
// Deprecated: IngestionAwareTransport is not used and may be removed in a future
|
||||
// version. Define the interface locally instead of referencing this exported
|
||||
// interface.
|
||||
type IngestionAwareTransport interface {
|
||||
Transport
|
||||
// IngestPacket pulls a single packet off the conn, and only closes it if shouldClose is true.
|
||||
IngestPacket(conn net.Conn, addr net.Addr, now time.Time, shouldClose bool) error
|
||||
// IngestStream hands off the conn to the transport and doesn't close it.
|
||||
IngestStream(conn net.Conn) error
|
||||
}
|
||||
|
||||
type NodeAwareTransport interface {
|
||||
IngestionAwareTransport
|
||||
Transport
|
||||
WriteToAddress(b []byte, addr Address) (time.Time, error)
|
||||
DialAddressTimeout(addr Address, timeout time.Duration) (net.Conn, error)
|
||||
}
|
||||
@@ -102,22 +104,6 @@ type shimNodeAwareTransport struct {
|
||||
|
||||
var _ NodeAwareTransport = (*shimNodeAwareTransport)(nil)
|
||||
|
||||
func (t *shimNodeAwareTransport) IngestPacket(conn net.Conn, addr net.Addr, now time.Time, shouldClose bool) error {
|
||||
iat, ok := t.Transport.(IngestionAwareTransport)
|
||||
if !ok {
|
||||
panic("shimNodeAwareTransport does not support IngestPacket")
|
||||
}
|
||||
return iat.IngestPacket(conn, addr, now, shouldClose)
|
||||
}
|
||||
|
||||
func (t *shimNodeAwareTransport) IngestStream(conn net.Conn) error {
|
||||
iat, ok := t.Transport.(IngestionAwareTransport)
|
||||
if !ok {
|
||||
panic("shimNodeAwareTransport does not support IngestStream")
|
||||
}
|
||||
return iat.IngestStream(conn)
|
||||
}
|
||||
|
||||
func (t *shimNodeAwareTransport) WriteToAddress(b []byte, addr Address) (time.Time, error) {
|
||||
return t.WriteTo(b, addr.Addr)
|
||||
}
|
||||
|
||||
26
vendor/github.com/hashicorp/memberlist/util.go
сгенерированный
поставляемый
26
vendor/github.com/hashicorp/memberlist/util.go
сгенерированный
поставляемый
@@ -119,35 +119,35 @@ func moveDeadNodes(nodes []*nodeState, gossipToTheDeadTime time.Duration) int {
|
||||
return n - numDead
|
||||
}
|
||||
|
||||
// kRandomNodes is used to select up to k random nodes, excluding any nodes where
|
||||
// the filter function returns true. It is possible that less than k nodes are
|
||||
// kRandomNodes is used to select up to k random Nodes, excluding any nodes where
|
||||
// the exclude function returns true. It is possible that less than k nodes are
|
||||
// returned.
|
||||
func kRandomNodes(k int, nodes []*nodeState, filterFn func(*nodeState) bool) []*nodeState {
|
||||
func kRandomNodes(k int, nodes []*nodeState, exclude func(*nodeState) bool) []Node {
|
||||
n := len(nodes)
|
||||
kNodes := make([]*nodeState, 0, k)
|
||||
kNodes := make([]Node, 0, k)
|
||||
OUTER:
|
||||
// Probe up to 3*n times, with large n this is not necessary
|
||||
// since k << n, but with small n we want search to be
|
||||
// exhaustive
|
||||
for i := 0; i < 3*n && len(kNodes) < k; i++ {
|
||||
// Get random node
|
||||
// Get random nodeState
|
||||
idx := randomOffset(n)
|
||||
node := nodes[idx]
|
||||
state := nodes[idx]
|
||||
|
||||
// Give the filter a shot at it.
|
||||
if filterFn != nil && filterFn(node) {
|
||||
if exclude != nil && exclude(state) {
|
||||
continue OUTER
|
||||
}
|
||||
|
||||
// Check if we have this node already
|
||||
for j := 0; j < len(kNodes); j++ {
|
||||
if node == kNodes[j] {
|
||||
if state.Node.Name == kNodes[j].Name {
|
||||
continue OUTER
|
||||
}
|
||||
}
|
||||
|
||||
// Append the node
|
||||
kNodes = append(kNodes, node)
|
||||
kNodes = append(kNodes, state.Node)
|
||||
}
|
||||
return kNodes
|
||||
}
|
||||
@@ -185,18 +185,18 @@ func decodeCompoundMessage(buf []byte) (trunc int, parts [][]byte, err error) {
|
||||
err = fmt.Errorf("missing compound length byte")
|
||||
return
|
||||
}
|
||||
numParts := uint8(buf[0])
|
||||
numParts := int(buf[0])
|
||||
buf = buf[1:]
|
||||
|
||||
// Check we have enough bytes
|
||||
if len(buf) < int(numParts*2) {
|
||||
if len(buf) < numParts*2 {
|
||||
err = fmt.Errorf("truncated len slice")
|
||||
return
|
||||
}
|
||||
|
||||
// Decode the lengths
|
||||
lengths := make([]uint16, numParts)
|
||||
for i := 0; i < int(numParts); i++ {
|
||||
for i := 0; i < numParts; i++ {
|
||||
lengths[i] = binary.BigEndian.Uint16(buf[i*2 : i*2+2])
|
||||
}
|
||||
buf = buf[numParts*2:]
|
||||
@@ -204,7 +204,7 @@ func decodeCompoundMessage(buf []byte) (trunc int, parts [][]byte, err error) {
|
||||
// Split each message
|
||||
for idx, msgLen := range lengths {
|
||||
if len(buf) < int(msgLen) {
|
||||
trunc = int(numParts) - idx
|
||||
trunc = numParts - idx
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user