Code Monkey home page Code Monkey logo

lori's Introduction

Lori

Pony TCP classes reimagined.

Status

Lori is an alpha-level project. It should be relatively bug free but is undergoing extensive changes.

Installation

  • Install corral
  • corral add github.com/seantallen-org/lori.git --version 0.5.0
  • corral fetch to fetch your dependencies
  • use "lori" to include this package
  • corral run -- ponyc to compile your application

API Documentation

https://ponylang.github.io/lori/

lori's People

Contributors

niclash avatar seantallen avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

lori's Issues

Create StandaloneTCPListener and StandaloneTCPConnection

That provide the same API (as much as possible) with the Pony standard library classes. This is in part, to allow for easier transition over to lori, but also to show users how to put lori's components together into working actors.

Make trait callbacks private

As all calls to our callbacks like on_connected are coming from within the package, we don't need or want them to be public like they currently are.

This is a breaking change and we should rev a full minor version (as we are pre-1.0)

Release 0.2.0

Update to work with pony 0.47.0

After release

  • change pr.yml for linux from latest to release
  • change pr.yml for macOS from nightly to release
  • change cirrus.yml for freebsd from nightly to release

Limit number of connections started per listener

Currently, a listener will create a new connection each time there's a new connection. Allowing a limit to be set to avoid overusing resources should be added.

  • TCPListener constructors need to allow for a limit (i think it makes sense to require on, rather than having the default be infinity - but we could use limit = 0 as infinity)
  • TCPListener._accept is where that currently would need to go for main logic
  • When TCPConnection is started from a listener, it needs to get a reference to the listener so it can inform the listener when it shuts down
  • TCPConnection needs to inform the listener that started it when it shutsdown
  • TCPListener needs to keep track of open connections. adding for each new one created, removing when one shuts down

Open question:

What do we do with new connection requests while at the limit?

  • 1: Queue them and when we drop below the limit, spawn from queue
  • 2: Reject the connection

Add Happy Eyeballs support

Currently using underlying run time support that does happy eyeballs, but aren't accounting for it. This is completely fine for ipv4 only but not if someone was using ipv6.

Add FreeBSD CI

Using CirrusCI, it would be good to have FreeBSD CI run so verify that everything works with Kqueue on FreeBSD. Most Pony libraries don't need to do this but given the runtime and ASIO heavy nature of Lori, it makes sense to add.

Performance issue in tcp_connection

When expect is 0 I do:

                if _expect == 0 then
                  // get all available data
                  let data' = _read_buffer = recover Array[U8] end
                  data'.truncate(_bytes_in_read_buffer)
                  _bytes_in_read_buffer = 0
                  consume data'

We shouldn't truncate there. We should chop like we do in the else clause so that we continue to use the large buffer we allocated.

Add backpressure to sending

Currently TCPConnection doesn't have any backpressure mechanism.

Should check when it can't send (because of backpressure) and then use the built-in Pony backpressure system until such time as it because writeable again at which point it should release the backpressure.

Add MacOS CI

Using CirrusCI, it would be good to have MacOS CI run so verify that everything works with Kqueue on MacOS. Most Pony libraries don't need to do this but given the runtime and ASIO heavy nature of Lori, it makes sense to add.

Switch to using OneShot for ASIO events in `TCPConnectionActor`

Currently using edge triggering.

This will involve updating the type from read_write() to read_write_oneshot() on event creation and putting resubscribe event calls in the correct locations in TCPConnectionActor.

I don't see any point at the moment to switching TCPListenerActor over.

Don't silently drop data when trying to send on a closed connection

Currently send on a TCPConnectionActor looks like:

  fun ref send(data: ByteSeq) =>
    if self().state is Open then
      try
        PonyTCP.send(self().event, data, data.size())?
    end

If the connection is closed, or there is otherwise an error, that is silently eaten. Ideally what is needed here is some sort of return that allows a caller to know if there was success or not. Then, you could write a behavior like:

be send(sender: SuccessCallbackHaver, data: ByteSeq) =>
  if not send(data) then
    sender.failure()
  end

to indicate the lack of success.

Rework Interface/TCPConnection relationship

Most of the functionality in the interface as default behavior can be moved into the TCPConnection. Start with moving everything that uses PonyASIO (except maybe connect) and PonyTCP into the TCPConnection class.

For this to work, there needs to be a callback into the actor from TCPConnection to call the various hooks. Need to figure out when that gets set in TCPConnection. Ideally on initialization but that might be difficult right now without some reworking.

`make test` should only run tests

Building the examples is overkill when wanting to run the test suite.

Should be:

  • ci task that runs both
  • test that only runs the tests
  • make-examples that only does the examples

Default for make should be ci.

Circle-ci needs to be updated as part of this.

Add Windows CI

With CirrusCI, It would be good to have Windows CI run so verify that everything works with IOCP on Windows. Most Pony libraries don't need to do this but given the runtime and ASIO heavy nature of Lori, it makes sense to add.

I'm not sure that the current version of Lori works with Windows as I haven't tested with it at all.

Add "mute" functionality

1- it's nice to have to be able to say "stop reading for a bit for something other than a back pressure reason"

2- it's not easy to do right now as all the "read" functionality is inside TCPConnection. The question is, how, after "mute" is received by an actor does it go about stopping reading.

I'm thinking simple mute and unmute options on TCPConnection

Run tests against Ponyc release

Currently, Lori's normal CI tests (as compared to daily cron against latest) are being run against latest instead of release as Ponyc 0.28.1 has a "bug" that prevents Lori tests from passing. The issue is fixed on master. When the next version of Pony is release (early July is most likely), CircleCI should be switched back to ponyc:release for the following jobs:

  • release-vs-ponyc-release:
  • debug-vs-ponyc-release:

make examples always builds them

Even if they don't need to be rebuilt. In the end, they should operate like the tests and only get built when something changes.

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.