Documentation
¶
Overview ¶
Package ldiff provides a container of elements with fixed id and changeable content. Diff can calculate the difference with another diff container (you can make it remote) with minimum hops and traffic.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrElementNotFound = errors.New("ldiff: element not found")
Functions ¶
func ReleaseHasher ¶ added in v0.9.5
func ReleaseHasher(hasher *Hasher)
Types ¶
type CompareDiff ¶ added in v0.7.0
type Diff ¶
type Diff interface {
Remote
// Set adds or update elements in container
Set(elements ...Element)
// RemoveId removes element by id
RemoveId(id string) error
// Diff makes diff with remote container
Diff(ctx context.Context, dl Remote) (newIds, changedIds, removedIds []string, err error)
// Elements retrieves all elements in the Diff
Elements() []Element
// Element returns an element by id
Element(id string) (Element, error)
// Ids retrieves ids of all elements in the Diff
Ids() []string
// Hash returns hash of all elements in the diff
Hash() string
// Len returns count of elements in the diff
Len() int
// DiffType returns the diff type (diff logic and parameters)
DiffType() spacesyncproto.DiffType
}
Diff contains elements and can compare it with Remote diff
func New ¶
New creates precalculated Diff container
divideFactor - means how many hashes you want to ask for once
it must be 2 or greater normal value usually between 4 and 64
compareThreshold - means the maximum count of elements remote diff will send directly
if elements under range will be more - remote diff will send only hash it must be 1 or greater normal value between 8 and 64
Less threshold and divideFactor - less traffic but more requests
type DiffContainer ¶ added in v0.3.11
type DiffContainer interface {
DiffTypeCheck(ctx context.Context, typeChecker RemoteTypeChecker) (needsSync bool, diff Diff, err error)
OldDiff() Diff
NewDiff() Diff
RemoveId(id string) error
}
func NewDiffContainer ¶ added in v0.3.11
func NewDiffContainer(new, old Diff) DiffContainer
type RangeResult ¶
RangeResult response for Range
type Remote ¶
type Remote interface {
// Ranges calculates given ranges and return results
Ranges(ctx context.Context, ranges []Range, resBuf []RangeResult) (results []RangeResult, err error)
}
Remote interface for using in the Diff
type RemoteTypeChecker ¶ added in v0.3.11
Directories
¶
| Path | Synopsis |
|---|---|
|
Package mock_ldiff is a generated GoMock package.
|
Package mock_ldiff is a generated GoMock package. |
Click to show internal directories.
Click to hide internal directories.