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

feat(gzip): add gzip compression on update bot #137

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from

Conversation

reyhansofian
Copy link

this PR will add gzip compression on update bot method. Why use gzip on update bot? Sometimes our users have enormous size of bot definitions and the http library (on zaun library) only has 60sec timeout by default (sadly we can't change it tho). Thus we need to change the update bot mechanism using another http client library

@reyhansofian reyhansofian self-assigned this Oct 28, 2019
components/api/api.ts Outdated Show resolved Hide resolved
@@ -1,6 +1,7 @@

import { JsonObject, Component } from "merapi";
import { IHelper } from "interfaces/main";
const pkg = require("../../package.json");
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ak kurang yakin apakah kita benar2 perlu ini 😅

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ini buat ambil sourcing version nya kan?

Comment on lines +38 to +39
this.timeout = this.helper.getProp("timeout") as number || 300000;
this.gzip = this.helper.getProp("gzip") as string || "false";
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ini seperti hidden features di sini 😂
mungkin kita perlu mendokumentasikannya lebih baik untuk options yg bisa dipakai oleh user

Copy link
Contributor

@oktavianidewi oktavianidewi Nov 18, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iya. aku kepikiran ide, kalo saat push, file size nya dibaca dulu, baru user bs milih mau di push pake di-compress atau nggak, gimana mas? wkkk

Comment on lines +25 to +28
this.spinner = ora({
discardStdin: false,
spinner: "line",
})
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ini untuk progress barnya. ak memilih spinner yg line karena hanya itu saja yg disupport di Windows

Copy link
Contributor

@oktavianidewi oktavianidewi Nov 18, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iya gpp lah mas. padahal yg dots lebih ai-ketching ya lol

Comment on lines +219 to +226
const url = `${this.api.apiClient.basePath}/projects/${projectId}/bot/revisions/${latestBotRevision}`;
const requestConfig: AxiosRequestConfig = {
headers: {
"Authorization": this.api.bearer.apiKey,
"user-agent": `kata-cli@${this.api.version}`,
},
timeout: this.api.timeout,
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kita pke axios untuk custom requestnya. agak tedious pada saat ngebuild url nya

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gpp mas, sementara gini aja dulu. nanti di kata-cli yg baru dibikin schema api call buat axios request nya biar g tedious

Comment on lines +230 to +232
const botString = JSON.stringify(data);
headers["content-encoding"] = "deflate";
headers["content-type"] = "application/json";
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

api gateway kita perlu dua headers ini supaya bisa decompress data yg terkirim

const botString = JSON.stringify(data);
headers["content-encoding"] = "deflate";
headers["content-type"] = "application/json";
const gzip = zlib.deflateSync(botString, { });
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kita menggunakan stdlib compression punya nodejs karena saat ini api gateway kita masih belum bisa handle compression dari library lain

@@ -0,0 +1,83 @@
{
"name": "kata-cli",
"version": "2.5.0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ini harusnya 2.5.1, bs di tsc lagi dulu

Copy link
Contributor

@oktavianidewi oktavianidewi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aku ada reply

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants