snazy commented on PR #1904: URL: https://github.com/apache/polaris/pull/1904#issuecomment-3187497663
Thanks for removing the secrets. But I still believe that it can be simplified, and have the currently missing the failure notifications. I've proposed a way to achieve this using Java pseudo code on the dev-ML. Adding it here as well below. ```java public interface EventListener { /** * "Dummy event foo" about to happen, with parameters x + y, no additional information collected * for "after the fact". */ InFlightVoid beforeEventFoo(String x, int y); /** About to commit to an Iceberg table. */ InFlight<IcebergTableCommitted> beforeIcebergTableCommit(UpdateTableRequest updateTableRequest); } public interface InFlight<SUCCESS_PAYLOAD> { /** Called "after the fact". */ void success(SUCCESS_PAYLOAD payload); /** Potentially called "after the fact" in case of a failure. */ void failure(Throwable throwable); /** Potentially called "after the fact" in case of a failure. */ void failure(String reason); } /** Convenience for events that do not have a success-payload. */ public interface InFlightVoid extends InFlight<Void> { default void success() { success(null); } } /** Success-payload for table-committed. */ public record IcebergTableCommitted(TableMetadata originalState, TableMetadata newState) {} ``` Example for a simple event "foo", w/o a success-payload: ```java public interface Foo { void doFoo(); } class FooImpl implements Foo { EventListener eventListener; @Override public void doFoo() { InFlightVoid event = eventListener.beforeEventFoo("foo", 42); try { // do foo stuff event.success(); } catch (Exception x) { event.failure(x); } } } ``` Example for table committed, with update-request, before and after states. Up to the event listener implementation which parts are consumed. ```java public interface Commit { void doCommit(UpdateTableRequest updateTableRequest); } class CommitImpl implements Commit { EventListener eventListener; @Override public void doCommit(UpdateTableRequest updateTableRequest) { InFlight<IcebergTableCommitted> event = eventListener.beforeIcebergTableCommit(updateTableRequest); try { // do table commit TableMetadata previousTableMetadata = ...; if (somePreconditionFailed) { event.failure("Precondition xyz failed"); return; } TableMetadata updatedTableMetadata = ...; event.success(new IcebergTableCommitted(previousTableMetadata, updatedTableMetadata)); } catch (Exception x) { event.failure(x); } } } ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@polaris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org