Skip to content
Snippets Groups Projects

Draft: HTTP promises

Open Gabe Rogan requested to merge http-promises into master
2 unresolved threads

This proves that we can easily add an async HTTP library and get a performance boost in not having to pause/resume the VM on every HTTP call. This is a complex operation that can be avoided and saves time and memory, on QuickJS especially.

This is still a draft because I haven't taken the time to convert our Pager's nextPage method to optionally return a promise.

Edited by Gabe Rogan

Merge request reports

Loading

Merge details

  • The source branch is 633 commits behind the target branch.
  • 1 commit and 1 merge commit will be added to master.
  • Source branch will be deleted.

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
111
112 @kotlinx.serialization.Serializable
113 class BridgeHttpResponse(val url: String, val code: Int, val body: String?, val headers: Map<String, List<String>>? = null) : IV8Convertable {
114 val isOk = code >= 200 && code < 300;
115
116 override fun toV8(runtime: V8Runtime): V8Value? {
117 val obj = runtime.createV8ValueObject();
118 obj.set("url", url);
119 obj.set("code", code);
120 obj.set("body", body);
121 obj.set("headers", headers);
122 obj.set("isOk", isOk);
123 // return obj;
124 val v8ValuePromiseResolver = runtime.createV8ValuePromise()
125 v8ValuePromiseResolver.promise.resolve(obj);
126 return v8ValuePromiseResolver.promise
  • Gabe Rogan
    Gabe Rogan @gabe started a thread on the diff
  • 24
    25 class PackageHttpPromises: V8Package {
    26 @Transient
    27 private val _config: IV8PluginConfig;
    28 @Transient
    29 private val _client: ManagedHttpClient
    30 @Transient
    31 private val _clientAuth: ManagedHttpClient
    32 @Transient
    33 private val _packageClient: PackageHttpClient;
    34 @Transient
    35 private val _packageClientAuth: PackageHttpClient
    36
    37
    38 override val name: String get() = "HttpPromises";
    39 override val variableName: String get() = "httpx";
  • assigned to @gabe

  • Gabe Rogan changed the description

    changed the description

  • Please register or sign in to reply
    Loading