Last active
July 23, 2016 23:37
-
-
Save hongchaodeng/5f5141f11bdf1298423fd1c8b32a8b56 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 Storage interface { | |
// Put... | |
// 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, prevVersion int64) (cur runtime.Object, err error) | |
// Delete... | |
// 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, prevRev int64) (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) | |
// if version >=0, list should wait until we have seen object with version >= given version. | |
List(key string, version int64, ss ...selector.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.Selector) (WatchChan, error) | |
// | |
AddIndex(idxName, field string, g selector.FieldValueGetFunc) error | |
DeleteIndex(idxName string) | |
// | |
AddWatcherIndex(idxName, field string, g selector.FieldValueGetFunc) error | |
DeleteWatcherIndex(idxName string) | |
} | |
type FieldValueGetFunc func(field string, obj runtime.Object) (string, bool) | |
type Selector struct { | |
Op labels.Operator // TODO: define storage layer its own selector | |
Field string | |
Values []string | |
// | |
FVGetFunc FieldValueGetFunc | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment