Skip to content

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

Open
reyhansofian wants to merge 5 commits into
developfrom
fix/push-bot-with-gzip
Open

feat(gzip): add gzip compression on update bot#137
reyhansofian wants to merge 5 commits into
developfrom
fix/push-bot-with-gzip

Conversation

@reyhansofian

Copy link
Copy Markdown

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
Comment thread components/bots/bot.ts Outdated
Comment thread components/api/api.ts Outdated
Comment thread components/api/api.ts

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

Copy link
Copy Markdown
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
Copy Markdown
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 thread components/api/api.ts
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
Copy Markdown
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

@oktavianidewi oktavianidewi Nov 18, 2019

Copy link
Copy Markdown
Contributor

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 thread components/bots/bot.ts
Comment on lines +25 to +28
this.spinner = ora({
discardStdin: false,
spinner: "line",
})

Copy link
Copy Markdown
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

@oktavianidewi oktavianidewi Nov 18, 2019

Copy link
Copy Markdown
Contributor

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 thread components/bots/bot.ts
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
Copy Markdown
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
Copy Markdown
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 thread components/bots/bot.ts
Comment on lines +230 to +232
const botString = JSON.stringify(data);
headers["content-encoding"] = "deflate";
headers["content-type"] = "application/json";

Copy link
Copy Markdown
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

Comment thread components/bots/bot.ts
const botString = JSON.stringify(data);
headers["content-encoding"] = "deflate";
headers["content-type"] = "application/json";
const gzip = zlib.deflateSync(botString, { });

Copy link
Copy Markdown
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

Comment thread lib/package.json
@@ -0,0 +1,83 @@
{
"name": "kata-cli",
"version": "2.5.0",

Copy link
Copy Markdown
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

@oktavianidewi oktavianidewi left a comment

Copy link
Copy Markdown
Contributor

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