-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add TLS * Cache GO build Dockerfile * Add Node dialer * Refactor TS security and connection modules * Add benchmarking * Improved GO error handling
- Loading branch information
Showing
33 changed files
with
569 additions
and
155 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
.vscode | ||
coverage | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,16 @@ | ||
FROM golang:1.17.6-alpine3.15 AS build | ||
# syntax=docker/dockerfile:1.3 | ||
|
||
COPY src /src | ||
FROM golang:1.17-alpine AS build | ||
|
||
COPY src/go.* /src/ | ||
WORKDIR /src | ||
|
||
RUN GOOS=js GOARCH=wasm go build -o kafkagosaur.wasm | ||
RUN go mod download | ||
COPY src /src/ | ||
|
||
RUN --mount=type=cache,target=/root/.cache/go-build \ | ||
GOOS=js GOARCH=wasm go build -o kafkagosaur.wasm | ||
|
||
FROM scratch AS export | ||
|
||
COPY --from=build /src/kafkagosaur.wasm / |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import "./deps.ts"; | ||
|
||
const getEnv = (key: string): string => { | ||
const value = Deno.env.get(key); | ||
if (value === undefined) throw Error(`Undefined environment variable ${key}`); | ||
else return value; | ||
}; | ||
|
||
const broker = getEnv("BROKER"); | ||
const topic = getEnv("TOPIC"); | ||
const username = getEnv("SASL_USERNAME"); | ||
const password = getEnv("SASL_PASSWORD"); | ||
|
||
export { broker, password, topic, username }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export { | ||
bench, | ||
runBenchmarks, | ||
} from "https://deno.land/std@0.125.0/testing/bench.ts"; | ||
|
||
import "https://deno.land/x/dotenv@v3.2.0/load.ts"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import KafkaGoSaur from "../mod.ts"; | ||
import { SASLMechanism } from "../security/sasl.ts"; | ||
import { bench, runBenchmarks } from "./deps.ts"; | ||
import { broker, password, topic, username } from "./config.ts"; | ||
|
||
const nrOfMessages = 100000; | ||
|
||
const readerConfig = { | ||
brokers: [broker], | ||
topic, | ||
sasl: { | ||
mechanism: SASLMechanism.PLAIN, | ||
username, | ||
password, | ||
}, | ||
tls: { | ||
insecureSkipVerify: true, | ||
}, | ||
}; | ||
|
||
const kafkaGoSaur = new KafkaGoSaur(); | ||
const reader = await kafkaGoSaur.reader(readerConfig); | ||
|
||
bench({ | ||
name: `readMessage#${nrOfMessages}`, | ||
runs: 10, | ||
async func(b): Promise<void> { | ||
b.start(); | ||
|
||
for (let i = 0; i < nrOfMessages; i++) { | ||
await reader.readMessage(); | ||
} | ||
|
||
b.stop(); | ||
}, | ||
}); | ||
|
||
const benchmarkRunResults = await runBenchmarks(); | ||
|
||
console.log(benchmarkRunResults); | ||
console.log( | ||
`[kafkagosaur] readMessage msgs/s: ${ | ||
nrOfMessages / (benchmarkRunResults.results[0].measuredRunsAvgMs / 1000) | ||
}`, | ||
); | ||
|
||
await reader.close(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import KafkaGoSaur from "../mod.ts"; | ||
import { SASLMechanism } from "../security/sasl.ts"; | ||
import { bench, runBenchmarks } from "./deps.ts"; | ||
import { broker, password, topic, username } from "./config.ts"; | ||
|
||
const nrOfMessages = 100000; | ||
const msgBatchSize = 10000; | ||
const msgSize = 1024; | ||
|
||
const writerConfig = { | ||
address: broker, | ||
topic, | ||
sasl: { | ||
mechanism: SASLMechanism.PLAIN, | ||
username, | ||
password, | ||
}, | ||
tls: { | ||
insecureSkipVerify: true, | ||
}, | ||
}; | ||
|
||
const kafkaGoSaur = new KafkaGoSaur(); | ||
const writer = await kafkaGoSaur.writer(writerConfig); | ||
|
||
const value = new Uint8Array(msgSize); | ||
crypto.getRandomValues(value); | ||
|
||
bench({ | ||
name: `writeMessages#${nrOfMessages}`, | ||
runs: 10, | ||
async func(b): Promise<void> { | ||
b.start(); | ||
|
||
for (let i = 0; i < nrOfMessages / msgBatchSize; i++) { | ||
const msgs = []; | ||
|
||
for (let j = 0; j < msgBatchSize; j++) { | ||
msgs.push({ value }); | ||
} | ||
await writer.writeMessages(msgs); | ||
} | ||
|
||
b.stop(); | ||
}, | ||
}); | ||
|
||
const benchmarkRunResults = await runBenchmarks(); | ||
|
||
console.log(benchmarkRunResults); | ||
console.log( | ||
`[kafkagosaur] writeMessages msgs/s: ${ | ||
nrOfMessages / (benchmarkRunResults.results[0].measuredRunsAvgMs / 1000) | ||
}`, | ||
); | ||
|
||
await writer.close(); |
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.