Skip to content

Commit

Permalink
perf: additional logs to check wrong
Browse files Browse the repository at this point in the history
  • Loading branch information
kirinnee committed Feb 26, 2024
1 parent bd5e209 commit eed24c0
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 14 deletions.
2 changes: 1 addition & 1 deletion config/dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ service: helium
port: 11000

# "local" or "cluster"
type: cluster
type: local

# fast mode
# 1. does not start the cluster, automatically assumes that your cluster already created
Expand Down
8 changes: 4 additions & 4 deletions infra/root_chart/Chart.lock
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
dependencies:
- name: sulfoxide-bromine
repository: oci://ghcr.io/atomicloud/sulfoxide.bromine
version: 1.3.0
version: 1.4.0
- name: root-chart
repository: oci://ghcr.io/atomicloud/nitroso.zinc
version: 1.8.7
version: 1.17.2
- name: bun-cron-chart
repository: file://../cron_chart
version: 0.1.0
digest: sha256:c0b67557f5e7ff6f07cc7a380c7ce55acaf35e2513ce0faee938f5444c4d54fc
generated: "2023-12-31T11:14:29.679493+08:00"
digest: sha256:3ff9c590c293fa5bc7ddf3ff8ddb0774c68d5c719b89fca890e63ea153355d67
generated: "2024-02-26T12:43:34.276733+08:00"
4 changes: 2 additions & 2 deletions infra/root_chart/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ appVersion: "1.16.0"

dependencies:
- name: sulfoxide-bromine
version: 1.3.0
version: 1.4.0
condition: bromine.enable
alias: bromine
repository: oci://ghcr.io/atomicloud/sulfoxide.bromine
- name: root-chart
version: 1.8.7
version: 1.17.2
condition: zinc.enable
alias: zinc
repository: oci://ghcr.io/atomicloud/nitroso.zinc
Expand Down
6 changes: 3 additions & 3 deletions infra/root_chart/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ Root Chart to a single Service
| Repository | Name | Version |
|------------|------|---------|
| file://../cron_chart | scheduler(bun-cron-chart) | 0.1.0 |
| oci://ghcr.io/atomicloud/nitroso.zinc | zinc(root-chart) | 1.8.7 |
| oci://ghcr.io/atomicloud/sulfoxide.bromine | bromine(sulfoxide-bromine) | 1.3.0 |
| oci://ghcr.io/atomicloud/nitroso.zinc | zinc(root-chart) | 1.17.2 |
| oci://ghcr.io/atomicloud/sulfoxide.bromine | bromine(sulfoxide-bromine) | 1.4.0 |

## Values

Expand Down Expand Up @@ -42,7 +42,7 @@ Root Chart to a single Service
| serviceTree.platform | string | `"nitroso"` | |
| serviceTree.service | string | `"helium"` | |
| zinc.api.configMountPath | string | `"/app/Config"` | |
| zinc.api.image.repository | string | `"ghcr.io/atomicloud/nitroso.zinc/api-arm"` | |
| zinc.api.image.repository | string | `"ghcr.io/atomicloud/nitroso.zinc/api"` | |
| zinc.migration.enabled | bool | `false` | |

----------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion infra/root_chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ zinc:
api:
configMountPath: /app/Config
image:
repository: ghcr.io/atomicloud/nitroso.zinc/api-arm
repository: ghcr.io/atomicloud/nitroso.zinc/api

migration:
enabled: false
Expand Down
17 changes: 15 additions & 2 deletions src/domain/search_core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { From, TrainSchedule } from "./interface.ts";
import { stringify } from "querystring";
import moment from "moment";
import { SearcherConfig } from "../config/searcher.config.ts";
import { Logger } from "pino";

const f = fetchCookie(fetch);

Expand Down Expand Up @@ -62,9 +63,11 @@ interface TrainScheduleResp {

class SearchCore {
#config: SearcherConfig;
#logger: Logger;

constructor(config: SearcherConfig) {
constructor(config: SearcherConfig, logger: Logger) {
this.#config = config;
this.#logger = logger;
}

async mainKTMBPage(): Promise<MainPageToken> {
Expand Down Expand Up @@ -179,7 +182,17 @@ class SearchCore {
init,
);

const obj = (await r.json()) as TrainScheduleResp;
let o: TrainScheduleResp | null = null;
const text = await r.text();

try {
o = JSON.parse(text);
} catch (e) {
this.#logger.error(e, "Error parsing response from KTMB", { text });
throw e;
}

const obj = o as TrainScheduleResp;

const $ = cheerio.load(obj.data);

Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const caches = loadRedis(cfg);
const descope = loadDescope(cfg.auth.descope);
const auth: Auth = new DescopeAuth(descope, cfg.auth.descope);
const zincDate = new ZincDate();
const searchCore = new SearchCore(cfg.app.searcher);
const searchCore = new SearchCore(cfg.app.searcher, logger);
const searchBuilder = new SearcherBuilder(searchCore);
const detailFactory = new DetailFactory(cfg.error, cfg.app);
const utility = new Utility(detailFactory);
Expand Down

0 comments on commit eed24c0

Please sign in to comment.