Skip to content

Make it easier to reuse DocumentMetadataHandle #441

Closed
@jmakeig

Description

@jmakeig

I'd like to create a default metadata strategy and then extend that with custom properties each time I use it, for example, to add a batch ID collection when ingesting a batch. The with* methods on DocumentMetadataHandle, change the internal state and return this. Instead, it would be nice to modify state on a clone and return that.

final DocumentMetadataHandle meta  = new DocumentMetadataHandle() //
                .withCollections("raw", "sakila", "jdbc:mysql://localhost:3306/sakila") //
                .withPermission("bigpicture-reader", Capability.READ) //
                .withPermission("bigpicture-writer", Capability.INSERT, Capability.UPDATE);
…

// First batch
doc.write(…, meta.withCollections("batch-1234"));

…
// Second batch
doc.write(…, meta.withCollections("batch-5678"));

Instead, since the state of meta is changed with the withCollections(), the second invocation has both collections, not just the base plus the second batch collection.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions