Initialize existing group topic. There is a race condition when two users attempt to load the same topic at the same time. It's prevented at hub level.
(t *Topic)
| 626 | // Initialize existing group topic. There is a race condition when two users attempt to load |
| 627 | // the same topic at the same time. It's prevented at hub level. |
| 628 | func initTopicGrp(t *Topic) error { |
| 629 | t.cat = types.TopicCatGrp |
| 630 | |
| 631 | // TODO(gene): check and validate topic name |
| 632 | stopic, err := store.Topics.Get(t.name) |
| 633 | if err != nil { |
| 634 | return err |
| 635 | } else if stopic == nil { |
| 636 | return types.ErrTopicNotFound |
| 637 | } |
| 638 | |
| 639 | if err = t.loadSubscribers(); err != nil { |
| 640 | return err |
| 641 | } |
| 642 | |
| 643 | t.isChan = stopic.UseBt |
| 644 | |
| 645 | // t.owner is set by loadSubscriptions |
| 646 | |
| 647 | t.accessAuth = stopic.Access.Auth |
| 648 | t.accessAnon = stopic.Access.Anon |
| 649 | |
| 650 | // Assign tags & auxiliary data. |
| 651 | t.tags = stopic.Tags |
| 652 | t.aux = stopic.Aux |
| 653 | |
| 654 | t.public = stopic.Public |
| 655 | t.trusted = stopic.Trusted |
| 656 | |
| 657 | t.created = stopic.CreatedAt |
| 658 | t.updated = stopic.UpdatedAt |
| 659 | if !stopic.TouchedAt.IsZero() { |
| 660 | t.touched = stopic.TouchedAt |
| 661 | } |
| 662 | t.lastID = stopic.SeqId |
| 663 | t.delID = stopic.DelId |
| 664 | t.subCnt = stopic.SubCnt |
| 665 | |
| 666 | // Initialize channel for receiving session online updates. |
| 667 | t.supd = make(chan *sessionUpdate, 32) |
| 668 | |
| 669 | t.xoriginal = t.name // topic may have been loaded by a channel reader; make sure it's grpXXX, not chnXXX. |
| 670 | |
| 671 | return nil |
| 672 | } |
| 673 | |
| 674 | // Initialize system topic. System topic is a singleton, always in memory. |
| 675 | func initTopicSys(t *Topic) error { |
no test coverage detected
searching dependent graphs…