Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Evaluate Patch Support in TypedStore, or Introduce a TypedClient Wrapper for resource.Client #457

Open
IfSentient opened this issue Nov 5, 2024 · 0 comments

Comments

@IfSentient
Copy link
Collaborator

resource.TypedStore (and resource.Store) does not support Patch operations, in this case by design to imitate a KV store interface where the only option for updating is to replace an object (and Patch can have a few gotchas involved). However, users find it useful to be able to do patch operations from a typed interface like resource.TypedStore. We should evaluate either adding Patch support to the stores, or introducing something like resource.TypedClient which wraps resource.Client like so:

type TypedClient[T Object, L ListObject] struct {
    Client Client
}

func (t *TypedClient[T,L]) Get(ctx context.Context, identifier Identifier) (T, error) {
    obj, err := t.client.Get(ctx, identifier)
    if err != nil {
        var n T
        return n, err
    }
    return t.castObject(obj)
}

// ...etc. for all other Client methods 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant