pulumi / pulumi/pulumi-java

auto: Provide a better `EngineEvent` object model and callback design (visitor pattern?)

Open
#1,635 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area/automation-api kind/enhancement
Dominant language
Java
Stars
85
Forks
26
Avg merge
11h 49m
Merged PRs (30d)
22

Description

Currently, the way engine events are exposed are very similar to how the other languages expose it. The design looks more like the JSON wire protocol than a well design object model.

public class EngineEvent {
    public int getSequence() {
        return sequence;
    }

    public int getTimestamp() {
        return timestamp;
    }

    @Nullable
    public CancelEvent getCancelEvent() {
        return cancelEvent;
    }

    @Nullable
    public StandardOutputEvent getStandardOutputEvent() {
        return stdoutEvent;
    }

    @Nullable
    public DiagnosticEvent getDiagnosticEvent() {
        return diagnosticEvent;
    }

    @Nullable
    public PreludeEvent getPreludeEvent() {
        return preludeEvent;
    }

    // ...
}

public class CancelEvent {
}

public class StandardOutputEvent {
    // ...
}

// ...

There's no common base type for individual events.

When you receive an EngineEvent from the callback, you have to check which getter doesn't return null to know which actual event it is.

We can do better. We can have a better class hierarchy and could consider an improved callback design, like using the visitor pattern.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the current Java EngineEvent callback and its getter-based event classes, including CancelEvent, StandardOutputEvent, DiagnosticEvent, and PreludeEvent. Compare the existing object model with the issue's proposed common event hierarchy and visitor-style callback; done requires an agreed design for both the event types and callback behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend-api-design
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.