Skip to content

Commit

Permalink
Some lexicon work to get new label schemas to codegen properly (#615)
Browse files Browse the repository at this point in the history
  • Loading branch information
ericvolp12 authored Mar 11, 2024
2 parents 06c2c15 + 2e39f0e commit 937e139
Show file tree
Hide file tree
Showing 8 changed files with 103 additions and 46 deletions.
2 changes: 2 additions & 0 deletions api/atproto/admindefs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

57 changes: 56 additions & 1 deletion api/atproto/cbor_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions api/atproto/labeldefs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 0 additions & 6 deletions api/bsky/init.go
Original file line number Diff line number Diff line change
@@ -1,7 +1 @@
package bsky

import cbg "github.com/whyrusleeping/cbor-gen"

func init() {
cbg.MaxLength = 1000000
}
23 changes: 14 additions & 9 deletions gen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,28 @@ func main() {
for _, typ := range mst.CBORTypes() {
typVals = append(typVals, reflect.New(typ).Elem().Interface())
}
if err := cbg.WriteMapEncodersToFile("mst/cbor_gen.go", "mst", typVals...); err != nil {

genCfg := cbg.Gen{
MaxStringLength: 1_000_000,
}

if err := genCfg.WriteMapEncodersToFile("mst/cbor_gen.go", "mst", typVals...); err != nil {
panic(err)
}

if err := cbg.WriteMapEncodersToFile("repo/cbor_gen.go", "repo", repo.SignedCommit{}, repo.UnsignedCommit{}); err != nil {
if err := genCfg.WriteMapEncodersToFile("repo/cbor_gen.go", "repo", repo.SignedCommit{}, repo.UnsignedCommit{}); err != nil {
panic(err)
}

if err := cbg.WriteMapEncodersToFile("api/cbor_gen.go", "api", api.CreateOp{}); err != nil {
if err := genCfg.WriteMapEncodersToFile("api/cbor_gen.go", "api", api.CreateOp{}); err != nil {
panic(err)
}

if err := cbg.WriteMapEncodersToFile("util/labels/cbor_gen.go", "labels", labels.UnsignedLabel{}); err != nil {
if err := genCfg.WriteMapEncodersToFile("util/labels/cbor_gen.go", "labels", labels.UnsignedLabel{}); err != nil {
panic(err)
}

if err := cbg.WriteMapEncodersToFile("api/bsky/cbor_gen.go", "bsky",
if err := genCfg.WriteMapEncodersToFile("api/bsky/cbor_gen.go", "bsky",
bsky.FeedPost{}, bsky.FeedRepost{}, bsky.FeedPost_Entity{},
bsky.FeedPost_ReplyRef{}, bsky.FeedPost_TextSlice{}, bsky.EmbedImages{},
bsky.EmbedExternal{}, bsky.EmbedExternal_External{},
Expand Down Expand Up @@ -70,7 +75,7 @@ func main() {
panic(err)
}

if err := cbg.WriteMapEncodersToFile("api/atproto/cbor_gen.go", "atproto",
if err := genCfg.WriteMapEncodersToFile("api/atproto/cbor_gen.go", "atproto",
atproto.RepoStrongRef{},
atproto.SyncSubscribeRepos_Commit{},
atproto.SyncSubscribeRepos_Handle{},
Expand All @@ -90,15 +95,15 @@ func main() {
panic(err)
}

if err := cbg.WriteMapEncodersToFile("lex/util/cbor_gen.go", "util", lexutil.CborChecker{}, lexutil.LegacyBlob{}, lexutil.BlobSchema{}); err != nil {
if err := genCfg.WriteMapEncodersToFile("lex/util/cbor_gen.go", "util", lexutil.CborChecker{}, lexutil.LegacyBlob{}, lexutil.BlobSchema{}); err != nil {
panic(err)
}

if err := cbg.WriteMapEncodersToFile("events/cbor_gen.go", "events", events.EventHeader{}, events.ErrorFrame{}); err != nil {
if err := genCfg.WriteMapEncodersToFile("events/cbor_gen.go", "events", events.EventHeader{}, events.ErrorFrame{}); err != nil {
panic(err)
}

if err := cbg.WriteMapEncodersToFile("atproto/data/cbor_gen.go", "data", data.GenericRecord{}, data.LegacyBlobSchema{}, data.BlobSchema{}); err != nil {
if err := genCfg.WriteMapEncodersToFile("atproto/data/cbor_gen.go", "data", data.GenericRecord{}, data.LegacyBlobSchema{}, data.BlobSchema{}); err != nil {
panic(err)
}
}
13 changes: 6 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ require (
github.com/goccy/go-json v0.10.2
github.com/gocql/gocql v1.6.0
github.com/golang-jwt/jwt v3.2.2+incompatible
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510
github.com/gorilla/websocket v1.5.1
github.com/hashicorp/go-retryablehttp v0.7.5
github.com/hashicorp/golang-lru/arc/v2 v2.0.6
Expand Down Expand Up @@ -53,7 +52,7 @@ require (
github.com/scylladb/gocqlx/v2 v2.8.1-0.20230309105046-dec046bd85e6
github.com/stretchr/testify v1.8.4
github.com/urfave/cli/v2 v2.25.7
github.com/whyrusleeping/cbor-gen v0.0.0-20240201211319-bf2168ca937c
github.com/whyrusleeping/cbor-gen v0.1.0
github.com/whyrusleeping/go-did v0.0.0-20230824162731-404d1707d5d6
gitlab.com/yawning/secp256k1-voi v0.0.0-20230925100816-f2616030848b
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1
Expand All @@ -64,7 +63,7 @@ require (
go.opentelemetry.io/otel/sdk v1.21.0
go.opentelemetry.io/otel/trace v1.21.0
go.uber.org/automaxprocs v1.5.3
golang.org/x/crypto v0.17.0
golang.org/x/crypto v0.21.0
golang.org/x/sync v0.5.0
golang.org/x/text v0.14.0
golang.org/x/time v0.3.0
Expand Down Expand Up @@ -114,7 +113,7 @@ require (
github.com/google/uuid v1.4.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.1 // indirect
github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2
github.com/ipfs/bbloom v0.0.4 // indirect
github.com/ipfs/go-blockservice v0.5.2 // indirect
github.com/ipfs/go-ipfs-ds-help v1.1.1 // indirect
Expand All @@ -131,7 +130,7 @@ require (
github.com/jbenet/goprocess v0.1.4 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/klauspost/cpuid/v2 v2.2.6 // indirect
github.com/klauspost/cpuid/v2 v2.2.7 // indirect
github.com/lestrrat-go/blackmagic v1.0.1 // indirect
github.com/lestrrat-go/httpcc v1.0.1 // indirect
github.com/lestrrat-go/httprc v1.0.4 // indirect
Expand Down Expand Up @@ -166,8 +165,8 @@ require (
go.uber.org/atomic v1.11.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/mod v0.14.0 // indirect
golang.org/x/net v0.18.0 // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/net v0.21.0 // indirect
golang.org/x/sys v0.18.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20231120223509-83a465c0220f // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231120223509-83a465c0220f // indirect
google.golang.org/grpc v1.59.0 // indirect
Expand Down
Loading

0 comments on commit 937e139

Please sign in to comment.