this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

events: update to newer subscription wire protocol

+47 -74
+36 -61
events/cbor_gen.go
··· 186 186 } 187 187 } 188 188 189 - // t.Prev (string) (string) 189 + // t.Prev (cid.Cid) (struct) 190 190 if len("prev") > cbg.MaxLength { 191 191 return xerrors.Errorf("Value in field \"prev\" was too long") 192 192 } ··· 203 203 return err 204 204 } 205 205 } else { 206 - if len(*t.Prev) > cbg.MaxLength { 207 - return xerrors.Errorf("Value in field t.Prev was too long") 208 - } 209 - 210 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.Prev))); err != nil { 211 - return err 212 - } 213 - if _, err := io.WriteString(w, string(*t.Prev)); err != nil { 214 - return err 206 + if err := cbg.WriteCid(cw, *t.Prev); err != nil { 207 + return xerrors.Errorf("failed to write cid field t.Prev: %w", err) 215 208 } 216 209 } 217 210 ··· 261 254 return err 262 255 } 263 256 264 - // t.Blobs ([]string) (slice) 257 + // t.Blobs ([]cid.Cid) (slice) 265 258 if len("blobs") > cbg.MaxLength { 266 259 return xerrors.Errorf("Value in field \"blobs\" was too long") 267 260 } ··· 281 274 return err 282 275 } 283 276 for _, v := range t.Blobs { 284 - if len(v) > cbg.MaxLength { 285 - return xerrors.Errorf("Value in field v was too long") 286 - } 287 - 288 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(v))); err != nil { 289 - return err 290 - } 291 - if _, err := io.WriteString(w, string(v)); err != nil { 292 - return err 277 + if err := cbg.WriteCid(w, v); err != nil { 278 + return xerrors.Errorf("failed writing cid field t.Blobs: %w", err) 293 279 } 294 280 } 295 281 ··· 340 326 return err 341 327 } 342 328 343 - // t.Commit (string) (string) 329 + // t.Commit (cid.Cid) (struct) 344 330 if len("commit") > cbg.MaxLength { 345 331 return xerrors.Errorf("Value in field \"commit\" was too long") 346 332 } ··· 352 338 return err 353 339 } 354 340 355 - if len(t.Commit) > cbg.MaxLength { 356 - return xerrors.Errorf("Value in field t.Commit was too long") 357 - } 358 - 359 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Commit))); err != nil { 360 - return err 361 - } 362 - if _, err := io.WriteString(w, string(t.Commit)); err != nil { 363 - return err 341 + if err := cbg.WriteCid(cw, t.Commit); err != nil { 342 + return xerrors.Errorf("failed to write cid field t.Commit: %w", err) 364 343 } 365 344 366 345 // t.TooBig (bool) (bool) ··· 475 454 476 455 t.Seq = int64(extraI) 477 456 } 478 - // t.Prev (string) (string) 457 + // t.Prev (cid.Cid) (struct) 479 458 case "prev": 480 459 481 460 { 461 + 482 462 b, err := cr.ReadByte() 483 463 if err != nil { 484 464 return err ··· 488 468 return err 489 469 } 490 470 491 - sval, err := cbg.ReadString(cr) 471 + c, err := cbg.ReadCid(cr) 492 472 if err != nil { 493 - return err 473 + return xerrors.Errorf("failed to read cid field t.Prev: %w", err) 494 474 } 495 475 496 - t.Prev = (*string)(&sval) 476 + t.Prev = &c 497 477 } 478 + 498 479 } 499 480 // t.Repo (string) (string) 500 481 case "repo": ··· 518 499 519 500 t.Time = string(sval) 520 501 } 521 - // t.Blobs ([]string) (slice) 502 + // t.Blobs ([]cid.Cid) (slice) 522 503 case "blobs": 523 504 524 505 maj, extra, err = cr.ReadHeader() ··· 535 516 } 536 517 537 518 if extra > 0 { 538 - t.Blobs = make([]string, extra) 519 + t.Blobs = make([]cid.Cid, extra) 539 520 } 540 521 541 522 for i := 0; i < int(extra); i++ { 542 523 543 - { 544 - sval, err := cbg.ReadString(cr) 545 - if err != nil { 546 - return err 547 - } 548 - 549 - t.Blobs[i] = string(sval) 524 + c, err := cbg.ReadCid(cr) 525 + if err != nil { 526 + return xerrors.Errorf("reading cid field t.Blobs failed: %w", err) 550 527 } 528 + t.Blobs[i] = c 551 529 } 552 530 553 531 // t.Event (string) (string) ··· 583 561 if _, err := io.ReadFull(cr, t.Blocks[:]); err != nil { 584 562 return err 585 563 } 586 - // t.Commit (string) (string) 564 + // t.Commit (cid.Cid) (struct) 587 565 case "commit": 588 566 589 567 { 590 - sval, err := cbg.ReadString(cr) 568 + 569 + c, err := cbg.ReadCid(cr) 591 570 if err != nil { 592 - return err 571 + return xerrors.Errorf("failed to read cid field t.Commit: %w", err) 593 572 } 594 573 595 - t.Commit = string(sval) 574 + t.Commit = c 575 + 596 576 } 597 577 // t.TooBig (bool) (bool) 598 578 case "tooBig": ··· 633 613 return err 634 614 } 635 615 636 - // t.Cid (string) (string) 616 + // t.Cid (cid.Cid) (struct) 637 617 if len("cid") > cbg.MaxLength { 638 618 return xerrors.Errorf("Value in field \"cid\" was too long") 639 619 } ··· 650 630 return err 651 631 } 652 632 } else { 653 - if len(*t.Cid) > cbg.MaxLength { 654 - return xerrors.Errorf("Value in field t.Cid was too long") 655 - } 656 - 657 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.Cid))); err != nil { 658 - return err 659 - } 660 - if _, err := io.WriteString(w, string(*t.Cid)); err != nil { 661 - return err 633 + if err := cbg.WriteCid(cw, *t.Cid); err != nil { 634 + return xerrors.Errorf("failed to write cid field t.Cid: %w", err) 662 635 } 663 636 } 664 637 ··· 748 721 } 749 722 750 723 switch name { 751 - // t.Cid (string) (string) 724 + // t.Cid (cid.Cid) (struct) 752 725 case "cid": 753 726 754 727 { 728 + 755 729 b, err := cr.ReadByte() 756 730 if err != nil { 757 731 return err ··· 761 735 return err 762 736 } 763 737 764 - sval, err := cbg.ReadString(cr) 738 + c, err := cbg.ReadCid(cr) 765 739 if err != nil { 766 - return err 740 + return xerrors.Errorf("failed to read cid field t.Cid: %w", err) 767 741 } 768 742 769 - t.Cid = (*string)(&sval) 743 + t.Cid = &c 770 744 } 745 + 771 746 } 772 747 // t.Path (string) (string) 773 748 case "path":
+11 -13
events/events.go
··· 6 6 "fmt" 7 7 8 8 "github.com/bluesky-social/indigo/util" 9 + "github.com/ipfs/go-cid" 9 10 logging "github.com/ipfs/go-log" 10 11 "go.opentelemetry.io/otel" 11 12 ) ··· 125 126 // Repo is the DID of the repo this event is about 126 127 Repo string `cborgen:"repo"` 127 128 128 - Commit string `cborgen:"commit"` 129 - Prev *string `cborgen:"prev"` 130 - //Commit cid.Cid `cborgen:"commit"` 131 - //Prev *cid.Cid `cborgen:"prev"` 132 - 133 - Ops []*RepoOp `cborgen:"ops"` 129 + Commit cid.Cid `cborgen:"commit"` 130 + Prev *cid.Cid `cborgen:"prev"` 134 131 Blocks []byte `cborgen:"blocks"` 135 - TooBig bool `cborgen:"tooBig"` 132 + Ops []*RepoOp `cborgen:"ops"` 133 + Blobs []cid.Cid `cborgen:"blobs"` 134 + Time string `cborgen:"time"` 136 135 137 - Blobs []string `cborgen:"blobs"` 138 - 139 - Time string `cborgen:"time"` 136 + TooBig bool `cborgen:"tooBig"` 140 137 } 141 138 142 139 type RepoOp struct { 143 - Path string `cborgen:"path"` 144 - Action string `cborgen:"action"` 145 - Cid *string `cborgen:"cid"` 140 + Path string `cborgen:"path"` 141 + Action string `cborgen:"action"` 142 + // TODO: 'cid' field is required, but nullable 143 + Cid *cid.Cid `cborgen:"cid"` 146 144 } 147 145 148 146 type LabelBatch struct {