Created
July 29, 2016 17:32
-
-
Save hongchaodeng/a89978cc3d15a3c2946854fc62894b18 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Interface interface { | |
// Put puts an object on a key. | |
// if prevVersion < 0, we will set the object with current largest resource version, | |
// put the object on the key, and returns the stored object. | |
// If prevVersion >= 0, we will use it to do Compare-And-Swap against existing object's resource version. | |
// Note that prevVersion = 0 means no previous object on given key. | |
// - If compare failed, it will return current object (nil if non-exist) and StorageError of VersionConflicts. | |
// - If compare succeed, it will behave like "prevVersion < 0". | |
Put(key string, obj runtime.Object, c *Conditions) (cur runtime.Object, err error) | |
// Delete a key and its object. | |
// If prevVersion < 0, we will try to delete the object and return the deleted object. If no object existed | |
// on given key, we returns nil object and nil error. | |
// If prevVersion > 0, we will use it to do Compare-And-Delete against existing object's resource version. | |
// - If compare failed, it will return current object (nil if non-exist) and StorageError of VersionConflicts. | |
// - If compare succeed, it will behave like "prevVersion < 0". | |
Delete(key string, c *Conditions) (cur runtime.Object, err error) | |
// Get gets the most recent version of a key. | |
// What is "most recent version" of a key? -- A key that was modified by this interface | |
// should be reflected on read after write succeeded. | |
// If no object exists on the key, it will return nil object and nil error. | |
Get(key string) (cur runtime.Object, err error) | |
// List lists all objects with key that has given prefix, and satisfies selectors. | |
// If version >=0, list should wait until we have seen object with version >= given version. | |
List(prefix string, version int64, ss ...Selector) (objects []runtime.Object, globalRev int64, err error) | |
// WatchPrefix watches a prefix after given rev. If rev is 0, we will watch from current state. | |
// It returns notifications of any keys that has given prefix. | |
// Given selectors, it returns events that contained object of interest, either of current and previous. | |
// If there is any problem establishing the watch channel, it will return error. After channel is established, | |
// any error that happened will be returned from WatchChan immediately before it's closed. | |
WatchPrefix(ctx context.Context, prefix string, version int64, ss ...Selector) (WatchChan, error) | |
AddIndex(idxName, field string, g FieldValueGetFunc) error | |
DeleteIndex(idxName string) | |
AddWatcherIndex(idxName, field string, g FieldValueGetFunc) error | |
DeleteWatcherIndex(idxName string) | |
} | |
type Conditions struct { | |
PrevVersion unit64 | |
} | |
type FieldValueGetFunc func(field string, obj runtime.Object) (string, bool) | |
type Selector struct { | |
Op Operator | |
Field string | |
Values []string | |
FVGetFunc FieldValueGetFunc | |
} | |
type WatchChan <-chan WatchResponse | |
type WatchResponse struct { | |
Type watch.EventType | |
Object runtime.Object | |
PrevObject runtime.Object | |
Err error | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment