At a high level, this is what I've done and why:
- I'm moving the protobuf generation for the `protocol`, `discovery` and
`db` packages to the modern alternatives, and using `buf` to generate
because it's nice and simple.
- After trying various approaches on how to integrate the new types with
the existing code, I opted for splitting off our own data model types
from the on-the-wire generated types. This means we can have a
`FileInfo` type with nicer ergonomics and lots of methods, while the
protobuf generated type stays clean and close to the wire protocol. It
does mean copying between the two when required, which certainly adds a
small amount of inefficiency. If we want to walk this back in the future
and use the raw generated type throughout, that's possible, this however
makes the refactor smaller (!) as it doesn't change everything about the
type for everyone at the same time.
- I have simply removed in cold blood a significant number of old
database migrations. These depended on previous generations of generated
messages of various kinds and were annoying to support in the new
fashion. The oldest supported database version now is the one from
Syncthing 1.9.0 from Sep 7, 2020.
- I changed config structs to be regular manually defined structs.
For the sake of discussion, some things I tried that turned out not to
work...
### Embedding / wrapping
Embedding the protobuf generated structs in our existing types as a data
container and keeping our methods and stuff:
```
package protocol
type FileInfo struct {
*generated.FileInfo
}
```
This generates a lot of problems because the internal shape of the
generated struct is quite different (different names, different types,
more pointers), because initializing it doesn't work like you'd expect
(i.e., you end up with an embedded nil pointer and a panic), and because
the types of child types don't get wrapped. That is, even if we also
have a similar wrapper around a `Vector`, that's not the type you get
when accessing `someFileInfo.Version`, you get the `*generated.Vector`
that doesn't have methods, etc.
### Aliasing
```
package protocol
type FileInfo = generated.FileInfo
```
Doesn't help because you can't attach methods to it, plus all the above.
### Generating the types into the target package like we do now and
attaching methods
This fails because of the different shape of the generated type (as in
the embedding case above) plus the generated struct already has a bunch
of methods that we can't necessarily override properly (like `String()`
and a bunch of getters).
### Methods to functions
I considered just moving all the methods we attach to functions in a
specific package, so that for example
```
package protocol
func (f FileInfo) Equal(other FileInfo) bool
```
would become
```
package fileinfos
func Equal(a, b *generated.FileInfo) bool
```
and this would mostly work, but becomes quite verbose and cumbersome,
and somewhat limits discoverability (you can't see what methods are
available on the type in auto completions, etc). In the end I did this
in some cases, like in the database layer where a lot of things like
`func (fv *FileVersion) IsEmpty() bool` becomes `func fvIsEmpty(fv
*generated.FileVersion)` because they were anyway just internal methods.
Fixes #8247
101 lines
4.2 KiB
AMPL
101 lines
4.2 KiB
AMPL
module github.com/syncthing/syncthing
|
|
|
|
go 1.22.0
|
|
|
|
require (
|
|
github.com/AudriusButkevicius/recli v0.0.7-0.20220911121932-d000ce8fbf0f
|
|
github.com/alecthomas/kong v1.4.0
|
|
github.com/aws/aws-sdk-go v1.55.5
|
|
github.com/calmh/incontainer v1.0.0
|
|
github.com/calmh/xdr v1.2.0
|
|
github.com/ccding/go-stun v0.1.5
|
|
github.com/chmduquesne/rollinghash v4.0.0+incompatible
|
|
github.com/d4l3k/messagediff v1.2.1
|
|
github.com/getsentry/raven-go v0.2.0
|
|
github.com/go-ldap/ldap/v3 v3.4.8
|
|
github.com/gobwas/glob v0.2.3
|
|
github.com/greatroar/blobloom v0.8.0
|
|
github.com/hashicorp/golang-lru/v2 v2.0.7
|
|
github.com/jackpal/gateway v1.0.15
|
|
github.com/jackpal/go-nat-pmp v1.0.2
|
|
github.com/julienschmidt/httprouter v1.3.0
|
|
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51
|
|
github.com/maruel/panicparse/v2 v2.3.1
|
|
github.com/maxbrunsfeld/counterfeiter/v6 v6.8.1
|
|
github.com/maxmind/geoipupdate/v6 v6.1.0
|
|
github.com/miscreant/miscreant.go v0.0.0-20200214223636-26d376326b75
|
|
github.com/oschwald/geoip2-golang v1.11.0
|
|
github.com/pierrec/lz4/v4 v4.1.21
|
|
github.com/prometheus/client_golang v1.20.5
|
|
github.com/puzpuzpuz/xsync/v3 v3.4.0
|
|
github.com/quic-go/quic-go v0.48.1
|
|
github.com/rabbitmq/amqp091-go v1.10.0
|
|
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475
|
|
github.com/shirou/gopsutil/v4 v4.24.10
|
|
github.com/syncthing/notify v0.0.0-20210616190510-c6b7342338d2
|
|
github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d
|
|
github.com/thejerf/suture/v4 v4.0.5
|
|
github.com/urfave/cli v1.22.16
|
|
github.com/vitrun/qart v0.0.0-20160531060029-bf64b92db6b0
|
|
github.com/willabides/kongplete v0.4.0
|
|
go.uber.org/automaxprocs v1.6.0
|
|
golang.org/x/crypto v0.29.0
|
|
golang.org/x/net v0.31.0
|
|
golang.org/x/sys v0.27.0
|
|
golang.org/x/text v0.20.0
|
|
golang.org/x/time v0.8.0
|
|
golang.org/x/tools v0.27.0
|
|
google.golang.org/protobuf v1.35.2
|
|
sigs.k8s.io/yaml v1.4.0
|
|
)
|
|
|
|
require (
|
|
github.com/Azure/go-ntlmssp v0.0.0-20221128193559-754e69321358 // indirect
|
|
github.com/beorn7/perks v1.0.1 // indirect
|
|
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
|
|
github.com/certifi/gocertifi v0.0.0-20210507211836-431795d63e8d // indirect
|
|
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
|
github.com/cpuguy83/go-md2man/v2 v2.0.5 // indirect
|
|
github.com/davecgh/go-spew v1.1.1 // indirect
|
|
github.com/ebitengine/purego v0.8.1 // indirect
|
|
github.com/fsnotify/fsnotify v1.7.0 // indirect
|
|
github.com/go-asn1-ber/asn1-ber v1.5.7 // indirect
|
|
github.com/go-ole/go-ole v1.3.0 // indirect
|
|
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
|
|
github.com/gofrs/flock v0.12.1 // indirect
|
|
github.com/golang/snappy v0.0.4 // indirect
|
|
github.com/google/pprof v0.0.0-20241009165004-a3522334989c // indirect
|
|
github.com/google/uuid v1.6.0 // indirect
|
|
github.com/hashicorp/errwrap v1.1.0 // indirect
|
|
github.com/hashicorp/go-multierror v1.1.1 // indirect
|
|
github.com/jmespath/go-jmespath v0.4.0 // indirect
|
|
github.com/klauspost/compress v1.17.11 // indirect
|
|
github.com/lufia/plan9stats v0.0.0-20240909124753-873cd0166683 // indirect
|
|
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
|
|
github.com/nxadm/tail v1.4.11 // indirect
|
|
github.com/onsi/ginkgo/v2 v2.20.2 // indirect
|
|
github.com/oschwald/maxminddb-golang v1.13.1 // indirect
|
|
github.com/pkg/errors v0.9.1 // indirect
|
|
github.com/pmezard/go-difflib v1.0.0 // indirect
|
|
github.com/posener/complete v1.2.3 // indirect
|
|
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect
|
|
github.com/prometheus/client_model v0.6.1 // indirect
|
|
github.com/prometheus/common v0.60.0 // indirect
|
|
github.com/prometheus/procfs v0.15.1 // indirect
|
|
github.com/riywo/loginshell v0.0.0-20200815045211-7d26008be1ab // indirect
|
|
github.com/russross/blackfriday/v2 v2.1.0 // indirect
|
|
github.com/stretchr/objx v0.5.2 // indirect
|
|
github.com/stretchr/testify v1.9.0 // indirect
|
|
github.com/tklauser/go-sysconf v0.3.14 // indirect
|
|
github.com/tklauser/numcpus v0.9.0 // indirect
|
|
github.com/yusufpapurcu/wmi v1.2.4 // indirect
|
|
go.uber.org/mock v0.4.0 // indirect
|
|
golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c // indirect
|
|
golang.org/x/mod v0.22.0 // indirect
|
|
golang.org/x/sync v0.9.0 // indirect
|
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
|
)
|
|
|
|
// https://github.com/gobwas/glob/pull/55
|
|
replace github.com/gobwas/glob v0.2.3 => github.com/calmh/glob v0.0.0-20220615080505-1d823af5017b
|