Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shsms/ob-grpc
Grpc evaluation functions for Emacs org-babel
https://github.com/shsms/ob-grpc
emacs grpc org-babel org-mode
Last synced: 4 months ago
JSON representation
Grpc evaluation functions for Emacs org-babel
- Host: GitHub
- URL: https://github.com/shsms/ob-grpc
- Owner: shsms
- License: gpl-3.0
- Created: 2021-09-05T21:42:12.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-03-19T09:19:37.000Z (almost 3 years ago)
- Last Synced: 2024-04-14T03:25:08.656Z (10 months ago)
- Topics: emacs, grpc, org-babel, org-mode
- Language: Emacs Lisp
- Homepage:
- Size: 23.4 KB
- Stars: 8
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.org
- License: LICENSE
Awesome Lists containing this project
README
* ob-grpc
ob-grpc provides functions for making grpc calls through org-babel,
using [[https://github.com/fullstorydev/grpcurl][grpcurl]].** Installation
Not available on melpa yet. Currently the easiest way to install is
to use [[https://github.com/raxod502/straight.el][straight.el]]#+begin_src elisp
(straight-use-package
'(ob-grpc :type git :host github :repo "shsms/ob-grpc"))
#+end_srcOr with ~use-package~ + ~straight.el~
#+begin_src elisp
(use-package ob-grpc
:straight (ob-grpc :type git :host github :repo "shsms/ob-grpc")
:bind (:map org-mode-map
("C-c g i" . ob-grpc-init)
("C-c g b" . ob-grpc-insert-block)))
#+end_srcAlso install [[https://github.com/fullstorydev/grpcurl][grpcurl]].
Optionally, add the below to your ~init.el~ to prevent a confirmation request from
org-babel every time you execute a block:#+begin_src elisp
(defun my-org-confirm-babel-evaluate (lang body)
(not (member lang '(
"grpc"
;; other source languages
))))(setq org-confirm-babel-evaluate 'my-org-confirm-babel-evaluate)
#+end_src** Usage
*** Init
In an empty org buffer, run ~M-x ob-grpc-init~. This would add these
properties to the buffer:#+begin_src org
:PROPERTIES:
:GRPC-ENDPOINT: [::1]:8080
:PROTO-FILE: ./proto/service.proto
:PROTO-IMPORT-PATH: proto
:PLAIN-TEXT: yes
:GRPC-BLOCK-PREFIX: * TODO ${method}\n\n# ${decl}\n
:END:
#+end_src*Notes:*
- Update their values as necessary.
- When using TLS, set ~:PLAIN-TEXT:~ to ~no~.
- Separate multiple import paths by a space character.
- The ~:GRPC-BLOCK-PREFIX:~ is a template for a prefix to the org-babel
block. Check below for details on how to configure.*** Insert org-babel blocks
Run ~M-x ob-grpc-insert-block~. That would prompt for a method name,
with all the methods in the ~:PROTO-FILE:~ as completion options.
Choose one, and it will automatically insert an org block, with the
method name, and a template message for the request type of the
message. For example,#+begin_src org
> #+begin_src grpc :method echo.Echo.Echo
> {
> "str": ""
> }
> #+end_src
#+end_src*** Execute the block
Update the request object as necessary, and press ~C-c C-c~ inside the block.
*** Configure ~:GRPC-BLOCK-PREFIX:~
If you don't want any text to be added in front of each of your
org-babel blocks, this can be set to ~:GRPC-BLOCK-PREFIX: nil~. The
default value ~:GRPC-BLOCK-PREFIX: * TODO ${method}\n\n# ${decl}\n~ adds
a new TODO org-section, followed by a comment with the grpc declation
of the selected method. Here's a list of template arguments that can
be used here:- ~${method}~ :: the name of the method, without the name of the service.
- ~${method-full}~ :: the name of the method including the service name.
- ~${decl}~ :: the entire declaration of the grpc method, including the
name, request and return types.
- ~${req-type}~ :: the name of the request type.
- ~${resp-type}~ :: the name of the response type.** Troubleshooting
There is not a lot of error handling at the moment. So when something
doesn't work as expected, visit the ~*Messages*~ buffer. All the calls
to ~grpcurl~ and responses are logged there.No support for streaming grpc methods yet.