8000 JavaScript RPC changes by knutwannheden · Pull Request #5636 · openrewrite/rewrite · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

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

Merged
merged 21 commits into from
Jun 25, 2025
Merged

JavaScript RPC changes #5636

merged 21 commits into from
Jun 25, 2025

Conversation

knutwannheden
Copy link
Contributor
@knutwannheden knutwannheden commented Jun 18, 2025

Major Changes

  • New GetRef RPC request. This is very similar to GetObject but for "references"
  • Removed RewriteRpc.Context and thread-local scope management
  • Removed lazy initialization - JsonRpc must be provided at construction
  • marketplace is now a required parameter in all builders
  • Removed batchSize from builder API (use batchSize() method instead)

New Features

  • Added local reference tracking for better memory management
  • JavaScript server now appends to log files instead of overwriting

API Improvements

  • Simplified builder pattern: RewriteRpc.from(jsonRpc, marketplace).build()
  • JavaScript RPC uses its own thread-local binding: JavaScriptRewriteRpc.bind()
  • Added convenience methods for bundled JavaScript installations

Bug Fixes

  • Added client-side validation for required recipe options
  • Fixed marker serialization for OmitParentheses and Semicolon
  • Improved object reference tracking

This refactoring significantly reduces complexity while improving memory management and API clarity.

@knutwannheden knutwannheden changed the title js rpc JavaScript RPC changes Jun 20, 2025
* Add new `GetRef` and remove `ClearObjectMaps`

* Add some tests

* Simplify

* Simplify

* Simplify

* Simplify
@knutwannheden knutwannheden marked this pull request as ready for review June 24, 2025 14:49
Comment on lines +38 to +48
@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<>();

Copy link
Member

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?

Copy link
Contributor Author

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.

@knutwannheden knutwannheden merged commit 82ffd4c into main Jun 25, 2025
2 checks passed
@knutwannheden knutwannheden deleted the js-rpc branch June 25, 2025 07:34
@github-project-automation github-project-automation bot moved this from In Progress to Done in OpenRewrite Jun 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants
0