Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow WebSocket compression #105

Closed
jirenius opened this issue Aug 5, 2019 · 1 comment
Closed

Allow WebSocket compression #105

jirenius opened this issue Aug 5, 2019 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@jirenius
Copy link
Collaborator

jirenius commented Aug 5, 2019

Story

Resgate should have an option to enable WebSocket message compression.

This would effectively counter the bloated message size when receiving resources with multiple models containing the same key names.

Example
A collection of reference to models could look like this:

{
  "result": {
    "models": {
      "notes.note.1": {
        "id": 1,
        "message": "One"
      },
      "notes.note.10": {
        "id": 10,
        "message": "Ten"
      },
      "notes.note.2": {
        "id": 2,
        "message": "Two"
      },
      "notes.note.3": {
        "id": 3,
        "message": "Three"
      },
      "notes.note.4": {
        "id": 4,
        "message": "Four"
      },
      "notes.note.5": {
        "id": 5,
        "message": "Five"
      },
      "notes.note.6": {
        "id": 6,
        "message": "Six"
      },
      "notes.note.7": {
        "id": 7,
        "message": "Seven"
      },
      "notes.note.8": {
        "id": 8,
        "message": "Eight"
      },
      "notes.note.9": {
        "id": 9,
        "message": "Nine"
      }
    },
    "collections": {
      "notes.notes": [
        {
          "rid": "notes.note.1"
        },
        {
          "rid": "notes.note.2"
        },
        {
          "rid": "notes.note.3"
        },
        {
          "rid": "notes.note.4"
        },
        {
          "rid": "notes.note.5"
        },
        {
          "rid": "notes.note.6"
        },
        {
          "rid": "notes.note.7"
        },
        {
          "rid": "notes.note.8"
        },
        {
          "rid": "notes.note.9"
        },
        {
          "rid": "notes.note.10"
        }
      ]
    }
  },
  "id": 1
}

Due to the repetitiveness of the data, gzip compression would reduce this from 704 bytes to 202 bytes.

Implementation

If enabled in the configuration, the Gorilla WebSocket updater should have the EnableCompression flag set to true.

Since the Gorilla WebSocket Compression feature is still flagged as Experimental, Resgate should have compression disabled by default.

An option should be added to the configuration file. Since http compression might later be added, the option name should clearly indicate it is for the WebSocket:

wsCompression (boolean)
Flag telling if WebSocket per message compression (RFC 7692) is enabled.
Example: false

@jirenius jirenius added the enhancement New feature or request label Aug 5, 2019
@jirenius jirenius self-assigned this Aug 5, 2019
jirenius added a commit that referenced this issue Aug 5, 2019
…-compression

GH-105: Added option to enable WebSocket compression.
@jirenius
Copy link
Collaborator Author

jirenius commented Aug 5, 2019

Resolved in #106

@jirenius jirenius closed this as completed Aug 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant