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 ¶
This section is empty.
Types ¶
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 }
Diff contains elements and can compare it with Remote diff
func New ¶
New creates new 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 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
Click to show internal directories.
Click to hide internal directories.