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

[FEATURE] Make Template Writeable #391

Closed
dbwiddis opened this issue Jan 9, 2024 · 1 comment
Closed

[FEATURE] Make Template Writeable #391

dbwiddis opened this issue Jan 9, 2024 · 1 comment
Assignees
Labels
enhancement New feature or request untriaged

Comments

@dbwiddis
Copy link
Member

dbwiddis commented Jan 9, 2024

Is your feature request related to a problem?

The Template class does not properly impement Writeable:

  • there is no constructor taking StreamInput
  • the writeTo() implementation does not handle the List<Version>
// TODO: fix writeable when implementing get workflow API
@Override
public void writeTo(StreamOutput output) throws IOException {
    output.writeString(name);
    output.writeOptionalString(description);
    output.writeString(useCase);
    output.writeVersion(templateVersion);
    // output.writeList((List<? extends Writeable>) compatibilityVersion);
    output.writeMapWithConsistentOrder(workflows);
    if (user != null) {
        output.writeBoolean(true); // user exists
        user.writeTo(output);
    } else {
        output.writeBoolean(false); // user does not exist
    }
}

This is a similar issue to the resource mapping in #358 where output.writeList() needs a type that is supported in writeGenericValue. See StreamOutput line 663. These do not include the Version class.

The Version class itself (if not in a collection) can be written (it just writes the integer ID).

What solution would you like?

Option 1: Just don't implement writeable. We currently pass the template in the Response as a JSON string, parsing it at the other end.

Option 2: Properly make the whole template writeable so we don't have to use the string workaround. This should have improved performance.

For the specific TODO:

Manually write the list:

output.writeVInt(compatibilityVersion.size());
for (Version v : compatibilityVersion) {
  output.writeVersion(v);
}

And implement the corresponding readers in the constructor.

@dbwiddis dbwiddis added enhancement New feature or request untriaged labels Jan 9, 2024
@joshpalis joshpalis self-assigned this Jan 9, 2024
@joshpalis
Copy link
Member

Going with option 1 since we don't ever write the template object itself to a stream, only the template json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request untriaged
Projects
None yet
Development

No branches or pull requests

2 participants