-
Notifications
You must be signed in to change notification settings - Fork 434
JavaScript RPC changes #5636
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
JavaScript RPC changes #5636
Conversation
* Add new `GetRef` and remove `ClearObjectMaps` * Add some tests * Simplify * Simplify * Simplify * Simplify
rewrite-core/src/main/java/org/openrewrite/rpc/request/GetRef.java
Outdated
Show resolved
Hide resolved
rewrite-core/src/main/java/org/openrewrite/rpc/request/GetRefResponse.java
Outdated
Show resolved
Hide resolved
rewrite-core/src/test/java/org/openrewrite/rpc/GetRefRequestTest.java
Outdated
Show resolved
Hide resolved
rewrite-core/src/test/java/org/openrewrite/rpc/IndependentCacheManagementTest.java
Outdated
Show resolved
Hide resolved
rewrite-core/src/main/java/org/openrewrite/rpc/request/GetRef.java
Outdated
Show resolved
Hide resolved
rewrite-core/src/main/java/org/openrewrite/rpc/request/GetRefResponse.java
Outdated
Show resolved
Hide resolved
rewrite-core/src/test/java/org/openrewrite/rpc/GetRefRequestTest.java
Outdated
Show resolved
Hide resolved
rewrite-core/src/test/java/org/openrewrite/rpc/IndependentCacheManagementTest.java
Outdated
Show resolved
Hide resolved
# Conflicts: # .claude/settings.local.json
@RequiredArgsConstructor | ||
public static class Handler extends io.moderne.jsonrpc.JsonRpcMethod<GetRef> { | ||
private static final ExecutorService forkJoin = ForkJoinPool.commonPool(); | ||
|
||
private final Map<Integer, Object> remoteRefs; | ||
private final IdentityHashMap<Object, Integer> localRefs; | ||
private final AtomicInteger batchSize; | ||
private final AtomicBoolean trace; | ||
|
||
private final Map<Integer, BlockingQueue<List<RpcObjectData>>> inProgress = new ConcurrentHashMap<>(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So is the idea here that one side or the other of an RPC setup owns the reference to a particular object and that can be used to figure out if it is safe to evict it from a cache?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea is that either party should be allowed to cache both "objects" and "refs" (which ultimately might converge) without needing to coordinate the cache eviction with the other party. When a "ref" is unknown, it will then just send a "GetRef" request.
Major Changes
GetRef
RPC request. This is very similar toGetObject
but for "references"RewriteRpc.Context
and thread-local scope managementJsonRpc
must be provided at constructionmarketplace
is now a required parameter in all buildersbatchSize
from builder API (usebatchSize()
method instead)New Features
API Improvements
RewriteRpc.from(jsonRpc, marketplace).build()
JavaScriptRewriteRpc.bind()
Bug Fixes
OmitParentheses
andSemicolon
This refactoring significantly reduces complexity while improving memory management and API clarity.