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

[WIP] Add interfaces for refactoring work #1276

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft

Conversation

aaron-congo
Copy link
Contributor

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Copy link

github-actions bot commented Feb 5, 2025

Qodana Community for JVM

1 new problem were found

Inspection name Severity Problems
Unused assignment 🔶 Warning 1

💡 Qodana analysis was run in the pull request mode: only the changed files were checked

View the detailed Qodana report

To be able to view the detailed Qodana report, you can either:

  1. Register at Qodana Cloud and configure the action
  2. Use GitHub Code Scanning with Qodana
  3. Host Qodana report at GitHub Pages
  4. Inspect and use qodana.sarif.json (see the Qodana SARIF format for details)

To get *.log files or any other Qodana artifacts, run the action with upload-result option set to true,
so that the action will upload the files as the job artifacts:

      - name: 'Qodana Scan'
        uses: JetBrains/[email protected]
        with:
          upload-result: true
Contact Qodana team

Contact us at [email protected]

import org.checkerframework.checker.nullness.qual.Nullable;
import software.amazon.jdbc.plugin.customendpoint.CustomEndpointInfo;

public interface StorageService {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

boolean exists(String itemCategory, Object key);

*
* @param event the event to publish.
*/
void publish(Object event);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to replace Object with a simple interface message interface (even if such interface is empty)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wondering about that. I didn't add it because I think subscribers will have to cast the event whether there's an interface or not, since our events will be pretty generic. But I can see how it might be useful so I can add it.


package software.amazon.jdbc.util.monitoring;

public enum MonitorState {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CREATED?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does that indicate a monitor that has been instantiated but never run? With the current design the monitor service doesn't provide a method to submit a monitor without running it, we just have the "runIfAbsent" method which would automatically create and run the monitor. So I'm not sure if we'd ever have a monitor in this state.

private long lastUsedTimeNs;
private @Nullable Throwable exception;

public MonitorStatus(MonitorState state, long lastUsedTimeNs) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might need to make this class immutable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was also wondering about that. If we make it immutable the monitor will have to create a new MonitorStatus object each time it needs to update its state, which could be quite frequent since it will be regularly updating the lastUsedTime field. I was also wondering if we should get rid of the MonitorStatus object and just have its fields directly in the Monitor class. If we did that we would have to add getters to the Monitor interface (getMonitorState, getLastUsedTime, getException).


void stop();

MonitorStatus getStatus();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's an exception as part of MonitorStatus. Is it an unhandled exception that stops/breaks a monitor?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was my intention yes, it would be a reference to an exception that caused a monitor to unexpectedly stop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants