Skip to content

Commit 9cfda0f

Browse files
authored
fix: Making the event queue overridable (#473)
# Description Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly: - [X] Follow the [`CONTRIBUTING` Guide](../CONTRIBUTING.md). - [X] Make your Pull Request title in the <https://www.conventionalcommits.org/> specification. - Important Prefixes for [release-please](https://github.com/googleapis/release-please): - `fix:` which represents bug fixes, and correlates to a [SemVer](https://semver.org/) patch. - `feat:` represents a new feature, and correlates to a SemVer minor. - `feat!:`, or `fix!:`, `refactor!:`, etc., which represent a breaking change (indicated by the `!`) and will result in a SemVer major. - [X] Ensure the tests pass - [X] Appropriate READMEs were updated (if necessary) Fixes #<issue_number_goes_here> 🦕 Signed-off-by: Emmanuel Hugonnet <[email protected]>
1 parent bfdee13 commit 9cfda0f

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

client/base/src/main/java/io/a2a/client/MessageEvent.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,19 @@ public MessageEvent(Message message) {
2121
public Message getMessage() {
2222
return message;
2323
}
24-
}
25-
2624

25+
@Override
26+
public String toString() {
27+
String messageAsString = "{"
28+
+ "role=" + message.getRole()
29+
+ ", parts=" + message.getParts()
30+
+ ", messageId=" + message.getMessageId()
31+
+ ", contextId=" + message.getContextId()
32+
+ ", taskId=" + message.getTaskId()
33+
+ ", metadata=" + message.getMetadata()
34+
+ ", kind=" + message.getKind()
35+
+ ", referenceTaskIds=" + message.getReferenceTaskIds()
36+
+ ", extensions=" + message.getExtensions() + '}';
37+
return "MessageEvent{" + "message=" + messageAsString + '}';
38+
}
39+
}

server-common/src/main/java/io/a2a/server/events/EventQueue.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public int getQueueSize() {
9696

9797
public abstract void awaitQueuePollerStart() throws InterruptedException ;
9898

99-
abstract void signalQueuePollerStarted();
99+
public abstract void signalQueuePollerStarted();
100100

101101
public void enqueueEvent(Event event) {
102102
enqueueItem(new LocalEventQueueItem(event));
@@ -119,7 +119,7 @@ public void enqueueItem(EventQueueItem item) {
119119
LOGGER.debug("Enqueued event {} {}", event instanceof Throwable ? event.toString() : event, this);
120120
}
121121

122-
abstract EventQueue tap();
122+
public abstract EventQueue tap();
123123

124124
/**
125125
* Dequeues an EventQueueItem from the queue.
@@ -265,7 +265,7 @@ static class MainQueue extends EventQueue {
265265
taskId, onCloseCallbacks.size(), taskStateProvider != null);
266266
}
267267

268-
EventQueue tap() {
268+
public EventQueue tap() {
269269
ChildQueue child = new ChildQueue(this);
270270
children.add(child);
271271
return child;
@@ -310,7 +310,7 @@ public void awaitQueuePollerStart() throws InterruptedException {
310310
}
311311

312312
@Override
313-
void signalQueuePollerStarted() {
313+
public void signalQueuePollerStarted() {
314314
if (pollingStarted.get()) {
315315
return;
316316
}
@@ -415,7 +415,7 @@ private void internalEnqueueItem(EventQueueItem item) {
415415
}
416416

417417
@Override
418-
EventQueue tap() {
418+
public EventQueue tap() {
419419
throw new IllegalStateException("Can only tap the main queue");
420420
}
421421

@@ -425,7 +425,7 @@ public void awaitQueuePollerStart() throws InterruptedException {
425425
}
426426

427427
@Override
428-
void signalQueuePollerStarted() {
428+
public void signalQueuePollerStarted() {
429429
parent.signalQueuePollerStarted();
430430
}
431431

0 commit comments

Comments
 (0)