mirror of
https://github.com/octoleo/syncthing.git
synced 2024-11-06 05:17:49 +00:00
916ec63af6
This is a new revision of the discovery server. Relevant changes and non-changes: - Protocol towards clients is unchanged. - Recommended large scale design is still to be deployed nehind nginx (I tested, and it's still a lot faster at terminating TLS). - Database backend is leveldb again, only. It scales enough, is easy to setup, and we don't need any backend to take care of. - Server supports replication. This is a simple TCP channel - protect it with a firewall when deploying over the internet. (We deploy this within the same datacenter, and with firewall.) Any incoming client announces are sent over the replication channel(s) to other peer discosrvs. Incoming replication changes are applied to the database as if they came from clients, but without the TLS/certificate overhead. - Metrics are exposed using the prometheus library, when enabled. - The database values and replication protocol is protobuf, because JSON was quite CPU intensive when I tried that and benchmarked it. - The "Retry-After" value for failed lookups gets slowly increased from a default of 120 seconds, by 5 seconds for each failed lookup, independently by each discosrv. This lowers the query load over time for clients that are never seen. The Retry-After maxes out at 3600 after a couple of weeks of this increase. The number of failed lookups is stored in the database, now and then (avoiding making each lookup a database put). All in all this means clients can be pointed towards a cluster using just multiple A / AAAA records to gain both load sharing and redundancy (if one is down, clients will talk to the remaining ones). GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/4648
46 lines
1.3 KiB
Go
46 lines
1.3 KiB
Go
package logrus
|
|
|
|
import "time"
|
|
|
|
const defaultTimestampFormat = time.RFC3339
|
|
|
|
// The Formatter interface is used to implement a custom Formatter. It takes an
|
|
// `Entry`. It exposes all the fields, including the default ones:
|
|
//
|
|
// * `entry.Data["msg"]`. The message passed from Info, Warn, Error ..
|
|
// * `entry.Data["time"]`. The timestamp.
|
|
// * `entry.Data["level"]. The level the entry was logged at.
|
|
//
|
|
// Any additional fields added with `WithField` or `WithFields` are also in
|
|
// `entry.Data`. Format is expected to return an array of bytes which are then
|
|
// logged to `logger.Out`.
|
|
type Formatter interface {
|
|
Format(*Entry) ([]byte, error)
|
|
}
|
|
|
|
// This is to not silently overwrite `time`, `msg` and `level` fields when
|
|
// dumping it. If this code wasn't there doing:
|
|
//
|
|
// logrus.WithField("level", 1).Info("hello")
|
|
//
|
|
// Would just silently drop the user provided level. Instead with this code
|
|
// it'll logged as:
|
|
//
|
|
// {"level": "info", "fields.level": 1, "msg": "hello", "time": "..."}
|
|
//
|
|
// It's not exported because it's still using Data in an opinionated way. It's to
|
|
// avoid code duplication between the two default formatters.
|
|
func prefixFieldClashes(data Fields) {
|
|
if t, ok := data["time"]; ok {
|
|
data["fields.time"] = t
|
|
}
|
|
|
|
if m, ok := data["msg"]; ok {
|
|
data["fields.msg"] = m
|
|
}
|
|
|
|
if l, ok := data["level"]; ok {
|
|
data["fields.level"] = l
|
|
}
|
|
}
|