(ctx context.Context, docID string, docJSON []byte, isUser bool, timeReceived channels.FeedTimestamp)
| 715 | } |
| 716 | |
| 717 | func (c *changeCache) processPrincipalDoc(ctx context.Context, docID string, docJSON []byte, isUser bool, timeReceived channels.FeedTimestamp) { |
| 718 | |
| 719 | // Currently the cache isn't really doing much with user docs; mostly it needs to know about |
| 720 | // them because they have sequence numbers, so without them the sequence of sequences would |
| 721 | // have gaps in it, causing later sequences to get stuck in the queue. |
| 722 | princ, err := c.unmarshalCachePrincipal(docJSON) |
| 723 | if err != nil { |
| 724 | base.WarnfCtx(ctx, "changeCache: Error unmarshaling doc %q: %v", base.UD(docID), err) |
| 725 | return |
| 726 | } |
| 727 | sequence := princ.Sequence |
| 728 | |
| 729 | if sequence <= c.initialSequence { |
| 730 | return // Tap is sending us an old value from before I started up; ignore it |
| 731 | } |
| 732 | |
| 733 | // Now add the (somewhat fictitious) entry: |
| 734 | change := &LogEntry{ |
| 735 | Sequence: sequence, |
| 736 | TimeReceived: timeReceived, |
| 737 | IsPrincipal: true, |
| 738 | } |
| 739 | if isUser { |
| 740 | change.DocID = "_user/" + princ.Name |
| 741 | } else { |
| 742 | change.DocID = "_role/" + princ.Name |
| 743 | } |
| 744 | |
| 745 | base.InfofCtx(ctx, base.KeyChanges, "Received #%d (%q)", change.Sequence, base.UD(change.DocID)) |
| 746 | |
| 747 | changedChannels := c.processEntry(ctx, change) |
| 748 | |
| 749 | c.notifyChange(ctx, changedChannels) |
| 750 | } |
| 751 | |
| 752 | // processEntry handles a newly-arrived LogEntry and returns the changes channels from this revision. |
| 753 | // This can be any existing, removed or newly added channels. Its possible for channels slice returned to have duplicates |
no test coverage detected