Skip to content

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

Open
@IfSentient

Description

@IfSentient

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 

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions