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

Implement JSONRPC V2 #1353

Merged
merged 29 commits into from
Nov 7, 2023
Merged

Implement JSONRPC V2 #1353

merged 29 commits into from
Nov 7, 2023

Conversation

taooceros
Copy link
Member

@taooceros taooceros commented Sep 1, 2022

Tasks:

  • Implement JSONRPC Plugin Base (for both v1 and v2), and forward current parser to v2
  • Implement a full jsonrpc protocol based on https://github.com/microsoft/vs-streamjsonrpc
  • Pass the Query object to plugin as argument
  • Implement a python server
  • Implement python client to send request
  • Initialization Method
  • Wait System.Text.Json Support in https://github.com/microsoft/vs-streamjsonrpc (They have merged the PR, so we only need to wait for a release)
  • Finish Python Script example with ijson
  • Implement API call (we need a new identifier)

Motivation:

Currently our jsonrpc plugins are very limited. They are not able to visit any api that might receive a result in Flow. They are not able to cache in memory as flow run every single query in different instance.

This PR:

  • One Instance of plugin per lifetime
  • Communication based on StdIn/StdOut
  • Standard JsonRPC protocol with the help of https://github.com/microsoft/vs-streamjsonrpc
  • Most API in Flow are callable by JsonRPC Plugins (except some that are not json serializable)
  • Performance is much better (almost feel like a native plugin)
  • User can reload plugin by F5 so the development is no harder than before

Sample Python Code

jsonrpcv2.zip

Limitation

  • The JsonRPC client in python is hand-written, without any unit test currently. I couldn't find a suitable library for the job we want. Most JsonRPC library in Python are for HTTP Protocol.
  • Exception Handling can be confusing sometimes. For example, TypeError is used to detect whether flow sends the correct argument to the server, but this errors can also be raised inside the method.

Future Work

  • Support Node.js/Deno directly (We can use the library for vscode lsp easily to create the sample)

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

# Conflicts:
#	Flow.Launcher/Flow.Launcher.csproj
#	Flow.Launcher/Notification.cs
@github-actions

This comment has been minimized.

# Conflicts:
#	Flow.Launcher.Plugin/Query.cs
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@taooceros taooceros marked this pull request as ready for review June 25, 2023 04:22
@taooceros taooceros requested review from Garulf and JohnTheGr8 June 25, 2023 04:22
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@jjw24 jjw24 mentioned this pull request Sep 7, 2023
@jjw24 jjw24 modified the milestones: Future, 1.17.0 Sep 7, 2023
@github-actions

This comment has been minimized.

@jjw24
Copy link
Member

jjw24 commented Sep 11, 2023

what do we need to do to get current plugins to start using v2 ?

This comment has been minimized.

This comment has been minimized.

Copy link

github-actions bot commented Nov 4, 2023

@check-spelling-bot Report

🔴 Please review

See the 📂 files view, the 📜action log, or 📝 job summary for details.

Unrecognized words (23)
Actionkeywordassigned
addtional
Bidirection
Deno
hyperlink
ijson
jsonrpcv
linkbtn
Linq
lsp
metadatas
Nerdbank
NUnit
PYTHONPATH
Reloadable
reulst
RPCV
seperated
splited
streamjsonrpc
SYSLIB
systemtextjsonformatter
Tle
To accept these unrecognized words as correct, you could run the following commands

... in a clone of the git@github.com:Flow-Launcher/Flow.Launcher.git repository
on the jsonrpc_v2 branch (ℹ️ how do I use this?):

curl -s -S -L 'https://raw.githubusercontent.com/check-spelling/check-spelling/v0.0.22/apply.pl' |
perl - 'https://github.com/Flow-Launcher/Flow.Launcher/actions/runs/6752180862/attempts/1'

OR

To have the bot accept them for you, reply quoting the following line:
@check-spelling-bot apply updates.

Pattern suggestions ✂️ (1)

You could add these patterns to .github/actions/spelling/patterns.txt:

# Automatically suggested patterns
# hit-count: 9 file-count: 7
# version suffix <word>v#
(?:(?<=[A-Z]{2})V|(?<=[a-z]{2}|[A-Z]{2})v)\d+(?:\b|(?=[a-zA-Z_]))

Errors (5)

See the 📂 files view, the 📜action log, or 📝 job summary for details.

❌ Errors Count
ℹ️ candidate-pattern 3
❌ check-file-path 3
❌ ignored-expect-variant 6
ℹ️ no-newline-at-eof 1
ℹ️ non-alpha-in-dictionary 9

See ❌ Event descriptions for more information.

If the flagged items are 🤯 false positives

If items relate to a ...

  • binary file (or some other file you wouldn't want to check at all).

    Please add a file path to the excludes.txt file matching the containing file.

    File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.

    ^ refers to the file's path from the root of the repository, so ^README\.md$ would exclude README.md (on whichever branch you're using).

  • well-formed pattern.

    If you can write a pattern that would match it,
    try adding it to the patterns.txt file.

    Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.

    Note that patterns can't match multiline strings.

Copy link
Member

@jjw24 jjw24 left a comment

Choose a reason for hiding this comment

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

Good work thank you for implementing V2.

Before we can publicly announce this new feature, we will need to:

  1. Add documentation
  2. Add the example plugin you attached in this PR as HelloWorld plugin
  3. Add a way to automatically transition/convert existing plugins to V2

Let's make sure people can create V2 plugins easily.

@jjw24 jjw24 merged commit 8102ca9 into dev Nov 7, 2023
2 checks passed
@jjw24 jjw24 deleted the jsonrpc_v2 branch November 7, 2023 21:22
@jjw24 jjw24 removed the review in progress Indicates that a review is in progress for this PR label Nov 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants