Giter Site home page Giter Site logo

aiohttp-rpc's Introduction

import world


michael_sulyak = world.people.get_or_create(
  name='Michael Sulyak',
  site='https://sulyak.info/',
  linkedin='https://www.linkedin.com/in/michael-sulyak/',
)

while True:
  try:
    michael_sulyak.create_something_cool()
  except world.exceptions.BaseException:
    pass

aiohttp-rpc's People

Contributors

expert-m avatar kaveshnikov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

aiohttp-rpc's Issues

Provide a way to send notification from the server

To deliver notifications from the server to the client, it's conventional for the server to act as a client by sending an id-less request to the client - the JSON-RPC spec defines a client as the origin of request and the server as the origin of response objects and either node can fill either one or both of those roles. Would you consider providing a way for the server to send Request objects to the client?

WsJsonRpcClient callers not receiving ConnectionResetError

Within a WsJsonRpcClient async context, if an underlying socket connection fails while one or more tasks' API calls are in progress (ie, taking a few seconds, with either a long timeout or no timeout) then all these waiting tasks just hang in limbo, and don't see any exceptions.

It seems there's no mechanism for detecting the connection has died, and then calling .notify_all_about_error(exc) to throw the relevant exception up the chain for all of the current pending callers.

Is there any way to ensure access to all relevant exceptions for tasks calling remote API methods on a WsJsonRpcClient websocket connection?

Mutating state of started aiohttp.web.Application is deprecated

I migrated one of my codebases to aiohttp-rpc today and had pytest emit the following warning:

/[...]/aiohttp_rpc/server/websocket.py:22: DeprecationWarning: Changing state of started or joined application is deprecated
  http_request.app[self.ws_state_key] = weakref.WeakSet()

I aso do not expect that a library should interact with the app dictionary at all - a user could conceivably store something in app["rcp_websockets"] which aiohttp-rpc would then overwrite.

Problem/Solution: JSONRPC over HTTPS with self-signed certs

aiohttp-rpc framework is great, but doesn't seem to provide easy way to support self-signed certs and sessions (or user-provided SSLContext objects, or user provided CA bundle files).

To do this, I've needed to subclass off JsonRpcClient, to:

  • accept a constructor arg to provide custom SSL info
  • override .connect() to use a subclass of aiohttp.ClientSession
  • override .call() to capture session key after successful login

Also, subclass aiohttp.ClientSession to:

  • override .post() to inject ssl keyword (for user-provided custom SSL info), plus session key header

With these mods, I can now use self-signed certs on the server and validate them in the client with an SSLContext based on the server's CA public key

This is working, but it took me a fair effort to get it solid. I'd recommend allowing for a constructor arg for aiohttp_rpc.JsonRpcServer to allow users to provide their own SSL objects, to cover for cases of private connections with self-signed certs.

I'm happy to rework the company-proprietary code I did for this and send in proof of concept if needed.

Cheers
David

PEP 561 compatibility

Hello.
Thank you for your library. It saves us much time for RPC-API implementation. Unfortunately, It is not compatible with PEP 561, so we cannot use its type hints for type checking with mypy.

I can make a PR to fix this if you don't mind.

Custom aiohttp POST params

Hi, what do you think about possibility to pass params in aiohttp post request?
E.g, I want to pass my custom unique per request header or timeout.
I suppose, we can start from direct_call and send_json.
They can be modified this way:

async def direct_call(self, rpc_request: JsonRpcRequest, **kwargs) -> JsonRpcResponse:

and

async def send_json(self,
                        data: typing.Any, *,
                        without_response: bool = False, **kwargs) -> typing.Tuple[typing.Any, typing.Optional[dict]]:
        merged_kwargs = merge_kwargs(self.request_kwargs, kwargs) (IMO, kwargs should be prioritized)
        http_response = await self.session.post(self.url, json=data, **merged_kwargs)

The idea is, if you need some request customization, you will use direct_call, otherwise call.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.