Documentation ¶
Index ¶
- Constants
- func ExpandingStar(set base.Set) base.Set
- func ForChangedUsers(a, b AccessMap, fn func(user string))
- func IgnoringStar(set base.Set) base.Set
- func IsValidChannel(channel string) bool
- func SetFromArray(names []string, mode StarMode) (base.Set, error)
- func SetOf(names ...string) base.Set
- func ValidateChannelSet(set base.Set) error
- type AccessMap
- type ChangeLog
- func (cp *ChangeLog) Add(newEntry LogEntry)
- func (cp *ChangeLog) AddEntries(entries []*LogEntry)
- func (cp *ChangeLog) CopyRemovingEmptyEntries() *ChangeLog
- func (cp *ChangeLog) Dump()
- func (cp *ChangeLog) EntriesAfter(after uint64) []*LogEntry
- func (cp *ChangeLog) FilterAfter(after uint64)
- func (cp *ChangeLog) HasEmptyEntries() bool
- func (cp *ChangeLog) LastSequence() uint64
- func (c *ChangeLog) Len() int
- func (c *ChangeLog) Less(i, j int) bool
- func (c *ChangeLog) Sort()
- func (c *ChangeLog) Swap(i, j int)
- func (cp *ChangeLog) TruncateTo(maxLength int) int
- type ChannelMap
- type ChannelMapper
- type ChannelMapperOutput
- type ChannelRemoval
- type LogEntry
- type LogEntryType
- type StarMode
- type SyncRunner
- type TimedSet
- func (set TimedSet) Add(other TimedSet) bool
- func (set TimedSet) AddAtSequence(other TimedSet, atSequence uint64) bool
- func (set TimedSet) AddAtVbSequence(other TimedSet, atVbSequence VbSequence) bool
- func (set TimedSet) AddChannel(channelName string, atSequence uint64) bool
- func (set TimedSet) AllChannels() []string
- func (set TimedSet) AsSet() base.Set
- func (set TimedSet) Contains(ch string) bool
- func (set TimedSet) Copy() TimedSet
- func (set TimedSet) Equals(other base.Set) bool
- func (set TimedSet) MarshalJSON() ([]byte, error)
- func (set TimedSet) SequenceOnlySet() map[string]uint64
- func (set TimedSet) String() string
- func (setPtr *TimedSet) UnmarshalJSON(data []byte) error
- func (set TimedSet) UpdateAtSequence(other base.Set, sequence uint64) bool
- func (set TimedSet) UpdateIfPresent(other TimedSet)
- func (set TimedSet) Validate() error
- type VbSequence
- func (vbs VbSequence) AsVbSeq() base.VbSeq
- func (v VbSequence) CompareTo(other VbSequence) base.CompareResult
- func (vbs VbSequence) Copy() VbSequence
- func (vbs VbSequence) Equals(other VbSequence) bool
- func (v VbSequence) IsLTEClock(clock base.SequenceClock) bool
- func (vbs VbSequence) String() string
Constants ¶
const ( LogEntryDocument = LogEntryType(iota) LogEntryPrincipal LogEntryCheckpoint LogEntryRollback )
const ( Deleted = 1 << iota // This rev is a deletion Removed // Doc was removed from this channel Hidden // This rev is not the default (hidden by a conflict) Conflict // Document is in conflict at this time Branched // Revision tree is branched Added // Doc was added to this channel )
Bits in LogEntry.Flags
const ( RemoveStar = StarMode(iota) KeepStar ExpandStar )
const AllChannelWildcard = "*" // wildcard for 'all channels'
const DocumentStarChannel = "!" // doc channel for "visible to all users"
const UserStarChannel = "*" // user channel for "can access all docs"
Constants for the * channel variations
Variables ¶
This section is empty.
Functions ¶
func ExpandingStar ¶
If the set contains "*", returns a set of only "*". Else returns the original set.
func ForChangedUsers ¶
Calls the function for each user whose access is different between the two AccessMaps
func IgnoringStar ¶
Returns a set with any "*" channel removed.
func IsValidChannel ¶
func SetFromArray ¶
Creates a new Set from an array of strings. Returns an error if any names are invalid.
func SetOf ¶
Creates a set from zero or more inline string arguments. Channel names must be valid, else the function will panic, so this should only be called with hardcoded known-valid strings.
func ValidateChannelSet ¶
Types ¶
type AccessMap ¶
Maps user names (or role names prefixed with "role:") to arrays of channel or role names
type ChangeLog ¶
type ChangeLog struct { Since uint64 // Sequence this log is valid _after_, i.e. max sequence not in the log Entries []*LogEntry // Ordered entries }
A sequential log of document revisions added to a channel, used to generate _changes feeds. The log is sorted by increasing sequence number.
func (*ChangeLog) AddEntries ¶
func (*ChangeLog) CopyRemovingEmptyEntries ¶
Returns a copy without empty (no DocID) entries that resulted from revisions that have been replaced. Result does not share a slice with the original cp.
func (*ChangeLog) EntriesAfter ¶
Returns a slice of all entries added after the one with sequence number 'after'. (They're not guaranteed to have higher sequence numbers; sequences may be added out of order.)
func (*ChangeLog) FilterAfter ¶
Filters the log to only the entries added after the one with sequence number 'after.
func (*ChangeLog) HasEmptyEntries ¶
func (*ChangeLog) LastSequence ¶
func (*ChangeLog) TruncateTo ¶
Removes the oldest entries to limit the log's length to `maxLength`.
type ChannelMap ¶
type ChannelMap map[string]*ChannelRemoval
func (ChannelMap) ChannelsRemovedAtSequence ¶
func (channelMap ChannelMap) ChannelsRemovedAtSequence(seq uint64) (ChannelMap, string)
type ChannelMapper ¶
func NewChannelMapper ¶
func NewChannelMapper(fnSource string) *ChannelMapper
func NewDefaultChannelMapper ¶
func NewDefaultChannelMapper() *ChannelMapper
func (*ChannelMapper) MapToChannelsAndAccess ¶
func (mapper *ChannelMapper) MapToChannelsAndAccess(body map[string]interface{}, oldBodyJSON string, userCtx map[string]interface{}) (*ChannelMapperOutput, error)
type ChannelMapperOutput ¶
type ChannelMapperOutput struct { Channels base.Set Roles AccessMap // roles granted to users via role() callback Access AccessMap Rejection error }
* Result of running a channel-mapper function.
type ChannelRemoval ¶
type LogEntry ¶
type LogEntry struct { Sequence uint64 // Sequence number DocID string // Document ID RevID string // Revision ID Flags uint8 // Deleted/Removed/Hidden flags VbNo uint16 // vbucket number TimeSaved time.Time // Time doc revision was saved (just used for perf metrics) TimeReceived time.Time // Time received from tap feed Channels ChannelMap // Channels this entry is in or was removed from Skipped bool // Late arriving entry Type LogEntryType // Log entry type Value []byte // Snapshot metadata (when Type=LogEntryCheckpoint) PrevSequence uint64 // Sequence of previous active revision }
type SyncRunner ¶
type SyncRunner struct { sgbucket.JSRunner // "Superclass" // contains filtered or unexported fields }
An object that runs a specific JS sync() function. Not thread-safe!
func NewSyncRunner ¶
func NewSyncRunner(funcSource string) (*SyncRunner, error)
func (*SyncRunner) MapToChannelsAndAccess ¶
func (runner *SyncRunner) MapToChannelsAndAccess(body map[string]interface{}, oldBodyJSON string, userCtx map[string]interface{}) (*ChannelMapperOutput, error)
func (*SyncRunner) SetFunction ¶
func (runner *SyncRunner) SetFunction(funcSource string) (bool, error)
type TimedSet ¶
type TimedSet map[string]VbSequence
A mutable mapping from channel names to sequence numbers (interpreted as the sequence when the channel was added.)
func AtSequence ¶
Creates a new TimedSet from a Set plus a sequence
func TimedSetFromString ¶
Parses a string as generated from TimedSet.String(). Returns nil on failure. An empty string successfully parses to an empty TimedSet.
func (TimedSet) Add ¶
Merges the other set into the receiver. In case of collisions the earliest sequence wins.
func (TimedSet) AddAtSequence ¶
Merges the other set into the receiver at a given sequence. */
func (TimedSet) AddAtVbSequence ¶
func (set TimedSet) AddAtVbSequence(other TimedSet, atVbSequence VbSequence) bool
Merges the other set into the receiver at a given sequence. */
func (TimedSet) AddChannel ¶
func (TimedSet) AllChannels ¶
func (TimedSet) MarshalJSON ¶
func (TimedSet) SequenceOnlySet ¶
func (TimedSet) String ¶
Encodes a TimedSet as a string (as sent in the public _changes feed.) This string can later be turned back into a TimedSet by calling TimedSetFromString().
func (*TimedSet) UnmarshalJSON ¶
TimedSet can unmarshal from either:
- The regular format {"channel":vbSequence, ...}
- The sequence-only format {"channel":uint64, ...} or
- An array of channel names.
In the last two cases, all vbNos will be 0. In the latter case all the sequences will be 0.
func (TimedSet) UpdateAtSequence ¶
Updates membership to match the given Set. Newly added members will have the given sequence.
func (TimedSet) UpdateIfPresent ¶
For any channel present in both the set and the other set, updates the sequence to the value from the other set
type VbSequence ¶
Vb and Sequence struct that's compatible with sequence-only (global sequence) mode
func NewVbSequence ¶
func NewVbSequence(vbNo uint16, sequence uint64) VbSequence
func NewVbSimpleSequence ¶
func NewVbSimpleSequence(sequence uint64) VbSequence
func (VbSequence) AsVbSeq ¶
func (vbs VbSequence) AsVbSeq() base.VbSeq
func (VbSequence) CompareTo ¶
func (v VbSequence) CompareTo(other VbSequence) base.CompareResult
Compares to other VbSequence. If EITHER vbNo is nil, does a sequence-only comparison
func (VbSequence) Copy ¶
func (vbs VbSequence) Copy() VbSequence
func (VbSequence) Equals ¶
func (vbs VbSequence) Equals(other VbSequence) bool
func (VbSequence) IsLTEClock ¶
func (v VbSequence) IsLTEClock(clock base.SequenceClock) bool
Is sequence less than or equal to corresponding clock entry
func (VbSequence) String ¶
func (vbs VbSequence) String() string