kbfsedits

package
v2.1.0+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 19, 2018 License: BSD-3-Clause Imports: 9 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Prepare

func Prepare(edits []NotificationMessage) (string, error)

Prepare converts the given slice of notifications into a string suitable for sending/storing them.

Types

type EntryType

type EntryType string

EntryType indicates the type of the file that was edited.

const (
	// EntryTypeFile is for files that have been edited.  Note that
	// covers both regular files and executables.
	EntryTypeFile EntryType = "file"
	// EntryTypeDir is for directories that have been edited.
	EntryTypeDir EntryType = "dir"
	// EntryTypeSym is for symlinks that have been edited.
	EntryTypeSym EntryType = "sym"
)

type ModifyRange

type ModifyRange struct {
	Offset uint64
	Length uint64
}

ModifyRange represents a file modification. Length is 0 for a truncate.

type NotificationMessage

type NotificationMessage struct {
	Version  NotificationVersion
	Filename string
	Type     NotificationOpType
	Time     time.Time // server-reported time
	FileType EntryType
	Revision kbfsmd.Revision
	Device   kbfscrypto.VerifyingKey
	UID      keybase1.UID
	FolderID tlf.ID
	Params   *NotificationParams `json:",omitempty"`
	// contains filtered or unexported fields
}

NotificationMessage is a summary of a single edit notification in KBFS. It is meant to be encoded and decoded with JSON.

type NotificationOpType

type NotificationOpType string

NotificationOpType indicates the type of the operation that caused the notification.

const (
	// NotificationCreate is the type of an edit notification
	// representing a new file or directory creation.
	NotificationCreate NotificationOpType = "create"
	// NotificationModify is the type of an edit notification
	// representing a file modification.
	NotificationModify NotificationOpType = "modify"
	// NotificationRename is the type of an edit notification
	// representing a file or directory getting renamed.
	NotificationRename NotificationOpType = "rename"
	// NotificationDelete is the type of an edit notification
	// representing a file or directory getting deleted.
	NotificationDelete NotificationOpType = "delete"
)

type NotificationParams

type NotificationParams struct {
	OldFilename string        `json:",omitempty"` // for renames
	Modifies    []ModifyRange `json:",omitempty"` // for modifies
}

NotificationParams is used for op-type-specific data.

type NotificationVersion

type NotificationVersion int

NotificationVersion is the numeric version of the edit notification data structure.

const (
	// NotificationV1 is unused, but represents the original,
	// MD-ops-based edit notification list.
	NotificationV1 NotificationVersion = 1
	// NotificationV2 is the first version that stores JSON-encoded
	// notifications in chat messages.
	NotificationV2 NotificationVersion = 2
)

type TlfHistory

type TlfHistory struct {
	// contains filtered or unexported fields
}

TlfHistory maintains a history of the last N file edits from each writer in the TLF.

There will be two users of a TlfHistory instance:

  • One user (likely something outside of the kbfsedits package, e.g. libkbfs.folderBranchOps) will read notifications from the corresponding TLF and add them to this history. After adding a batch or several batches of messages, it should call `Recompute()`, and if some writers need more, earlier revisions, it should fetch more notifications for the indicated writer and repeat.

  • The other user (within the kbfsedits package) will collate the histories from multiple TlfHistory instances together using `getHistory()` from each one. It may also construct pretty versions of individual edit histories for a particular TLF.

func NewTlfHistory

func NewTlfHistory() *TlfHistory

NewTlfHistory constructs a new TlfHistory instance.

func (*TlfHistory) AddNotifications

func (th *TlfHistory) AddNotifications(
	writerName string, messages []string) (err error)

AddNotifications takes in a set of messages in this TLF by `writer`, and adds them to the history. Once done adding messages, the caller should call `Recompute` to find out if more messages should be added for any particular writer.

func (*TlfHistory) Recompute

func (th *TlfHistory) Recompute() (writersWhoNeedMore map[string]bool)

Recompute processes (and caches) the history so that it reflects all recently-added notifications, and returns the names of writers which don't yet have the maximum number of edits in the history.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL