Skip to content

Releases: moonbitlang/async

v0.18.1

23 Apr 09:23

Choose a tag to compare

  • refactor API of @fs.open and other helpers that invoke it:

    • a new enum CreateMode, passed via the flag create_mode is introduced. CreateMode provides five different modes controlling behavior of new file creation and truncation of existing file.
    • a new optional parameter permission is introduced for @fs.open, @fs.mkdir etc., to determine the Unix permission of create file/directory, if any. permission is optional and has a sane default value for each function
    • the create? : Int and truncate? : Bool parameters are deprecated, in favor of create_mode + permission

    In addition to style change, there are the following notable differences:

    • exclusive new file creation (raise error if file already exists) is now supported
    • permission of new file/directory is now optional
  • add global signal handling support via a new package moonbitlang/async/signal. When a program using moonbitlang/async receives SIGINT/SIGTERM/SIGHUP (Unix) or CTRL_C_EVENT/CTRL_BREAK_EVENT/CTRL_CLOSE_EVENT (Windows), the default behavior now becomes cancelling the whole async program gracefully, using moonbitlang/async's native cancellation mechanism. The set of signals that triggers this global cancellation behavior can be configured via @signal.set_global_cancellation_signals

  • the certificate of the peer in a TLS connection can now be retrieved via @tls.Tls::get_peer_certificate. The returned certificate is in DER format. This is useful for tls-server-endpoint style channel binding in SASL

  • add @fs.rename for asynchronously rename files and directories

  • on Windows, the TLS server implementation for testing no longer needs to load certificate into the system certificate store. Instead, it can now load certificate from local file directly. If you have previously added the certificate in test_keys to your system certificate store on Windows for testing moonbitlang/async, the certificate can now be removed via certutil -delstore -user My <cert-id>, where <cert-id> can be found via certutil -store -user My

v0.18.0

15 Apr 03:49

Choose a tag to compare

  • add a new package moonbitlang/async/raw_fd, which provides a type @raw_fd.RawFd for integrating a raw file descriptor into moonbitlang/async and performing asynchronous IO on it
  • [breaking] cookies are now stored separately in @http.Response, as an array of @http.Cookie, a structured type representing cookies. For client, they should no longer read Set-Cookie from headers. For server, cookies should now be supplied via the cookies field of @http.Response instead of manually passing Set-Cookie headers. This solves the previous problem where multiple Set-Cookie headers are handled incorrectly
  • [breaking] @websocket.from_http_client now raise a new error constructor WebSocketError::HandshakeRejected, which contains the server response header

v0.17.1

10 Apr 10:46

Choose a tag to compare

  • introduce moonbitlang/async/gzip, which provides gzip encoding/decoding in the form of @io.Writer/@io.Reader transformer
  • the HTTP client can now automatically request gzip compression and perform gzip decompression for response body, if Accept-Encoding is not explicitly set
  • Content-Length can now be manually set in the extra_headers parameter for various HTTP API. If Content-Length is manually set, the body can still be sent incrementally, but its final length must equal the value of Content-Length
  • the HTTP client now accepts a verify? : Bool = true parameter. If set to false, HTTPS certificate validation will be skipped. This flag should be used for testing only, as skipping certificate validation destroy the safety guarantee of HTTPS
  • adapt latest MoonBit version (v0.9.0)

v0.17.0

01 Apr 07:04

Choose a tag to compare

  • [breaking] the signature of @async.TaskGroup::spawn_loop has changed. The callback function should no longer return IterResult, because it is deprecated on moonbitlang/core. Instead, the callback function must now return Unit. To break away from spawn_loop, users can raise a special error type @async.BreakFromSpawnLoop instead
  • [breaking] @socket.TcpServer::new, @socket.UdpServer::new and @http.Server::new are now async
  • The following types can now be constructed via struct constructor syntax, saving ::new:
    • @async.Queue (aka @aqueue.Queue), @async.Semaphore (aka @semaphore.Semaphore) and @async.Cond (aka @cond_var.Cond)
    • @socket.{TcpServer,UdpServer,UdpClient}
    • @http.Server
  • the local address of @socket.{Tcp,TcpServer,UdpClient,UdpServer} and @http.Server can now be retrieved via struct field .addr directly. The getter methods .addr() are deprecated in favor of the field
  • adapt latest MoonBit version (v0.8.4)
  • various bug fix

v0.16.8

11 Mar 10:16

Choose a tag to compare

  • introduce a new time @async.Timer for more sophisticated timer operations, such as multiple waiters and timer renewal. The latter is especially useful for setting up an idle timeout mechanism. See #313 and the API doc for more details. You can also find a simple example at examples/idle_timeout
  • add .fd() method to @socket.{Tcp,TcpServer,UdpClient,UdpServer}, allowing users to manually bind platform specific socket API missing from moonbitlang/async/socket
  • remove some deprecated API

v0.16.7

02 Mar 05:42

Choose a tag to compare

  • add HTTP client support for JavaScript backend using fetch API. All HTTP client API in moonbitlang/async/http are available (except HTTP proxy support)
  • add @js_async.ReadableStream support for integration with WebAPI ReadableStream. Two scenarios are supported:
    • reading from a ReadableStream from the JS side
    • create an anonymous pipe whose read end is a JS ReadableStream, this allows passing data to foreign JS code via the ReadableStream interface
  • the HTTP client is now compatible with close-delimited response (i.e. no Content-Length nor Transfer-Encoding set, response is delimited by connection closure)
  • various bug fix

v0.16.6

10 Feb 03:36

Choose a tag to compare

  • fix a bug in @js_async, where Promise::from_async does not start the function immediately, which may result in program hang
  • adapt latest MoonBit version (v0.8.1)

v0.16.5

05 Feb 06:02

Choose a tag to compare

  • @async.Queue now support Blocking/DiscardOldest/DiscardLatest queues with zero buffer size. For blocking queues, zero buffer size means that data transfer can only happen if a reader and a writer is present at the same time
  • add advisory file locking support via @fs.File::{lock, try_lock, unlock}
  • add a new API @fs.tmpdir for creating temporary directory

v0.16.4

29 Jan 07:38

Choose a tag to compare

  • fix compilation error on Windows due to calling convention mismatch

v0.16.3

28 Jan 08:50

Choose a tag to compare

  • add @process.spawn(group, cmd, args, ..), which spawn a process inside the task group group, and return a handle @process.Process that can be used to retrieve the PID of the process or wait for the process. The child process follows structured concurrency rules:
    • unless no_wait=true the task group wait for the child process
    • when the task group is about to terminate, the child process will be cancelled if it is still running
    • with_task_group will only return after the child process actually terminates
  • @process.run, @process.spawn and @process.spawn_orphan now accepts StringView and ArrayView as arguments
  • cancelling a task via @async.Task::spawn will no longer fail the whole task group, even if the task is spawned with allow_failure=false (the default)
  • calling @async.TaskGroup::{spawn,spawn_bg} during the cleanup phrase of with_task_group (i.e. the group is about to terminate, all remaining child tasks are cancelled, but there are still child tasks running) will no longer crash the program. However, the spawned child task will be cancelled immediately. Calling spawn/spawn_bg inside group defer or after with_task_group returns will still crash the program, though
  • Child process spawned by @process.run/@process.spawn will now be killed automatically when the main process is killed on Windows
  • add more examples to examples, and add a brief introduction to most examples
  • adapt latest MoonBit version and fix bugs