Add context object to interfaces

This commit is contained in:
derekwaynecarr
2014-09-25 14:34:01 -04:00
parent 377a9ac3d7
commit 3e685674e7
15 changed files with 115 additions and 63 deletions

View File

@@ -17,6 +17,7 @@ limitations under the License.
package apiserver
import (
"code.google.com/p/go.net/context"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
@@ -30,20 +31,20 @@ type RESTStorage interface {
New() runtime.Object
// List selects resources in the storage which match to the selector.
List(label, field labels.Selector) (runtime.Object, error)
List(ctx context.Context, label, field labels.Selector) (runtime.Object, error)
// Get finds a resource in the storage by id and returns it.
// Although it can return an arbitrary error value, IsNotFound(err) is true for the
// returned error value err when the specified resource is not found.
Get(id string) (runtime.Object, error)
Get(ctx context.Context, id string) (runtime.Object, error)
// Delete finds a resource in the storage and deletes it.
// Although it can return an arbitrary error value, IsNotFound(err) is true for the
// returned error value err when the specified resource is not found.
Delete(id string) (<-chan runtime.Object, error)
Delete(ctx context.Context, id string) (<-chan runtime.Object, error)
Create(runtime.Object) (<-chan runtime.Object, error)
Update(runtime.Object) (<-chan runtime.Object, error)
Create(ctx context.Context, obj runtime.Object) (<-chan runtime.Object, error)
Update(ctx context.Context, obj runtime.Object) (<-chan runtime.Object, error)
}
// ResourceWatcher should be implemented by all RESTStorage objects that
@@ -53,11 +54,11 @@ type ResourceWatcher interface {
// are supported; an error should be returned if 'field' tries to select on a field that
// isn't supported. 'resourceVersion' allows for continuing/starting a watch at a
// particular version.
Watch(label, field labels.Selector, resourceVersion uint64) (watch.Interface, error)
Watch(ctx context.Context, label, field labels.Selector, resourceVersion uint64) (watch.Interface, error)
}
// Redirector know how to return a remote resource's location.
type Redirector interface {
// ResourceLocation should return the remote location of the given resource, or an error.
ResourceLocation(id string) (remoteLocation string, err error)
ResourceLocation(ctx context.Context, id string) (remoteLocation string, err error)
}