-
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 various JSDocs * Add `partition` config to KafkaReader * Change `KafkaGoSaur` constructor to take enums
- Loading branch information
Showing
10 changed files
with
144 additions
and
25 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
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,24 @@ | ||
/** | ||
* X509KeyPair holds a public/private key of PEM encoded data. | ||
*/ | ||
export type X509KeyPair = { | ||
key: string; | ||
cert: string; | ||
}; | ||
|
||
export type TLSConfig = boolean | { | ||
/** | ||
* Controls whether a client verifies the server's certificate chain and | ||
* host name. If set true, crypto/tls accepts any certificate presented | ||
* by the server and any host name in that certificate. In this mode, TLS | ||
* is susceptible to machine-in-the-middle attacks unless custom verification | ||
* is used. This should be used only for testing. | ||
*/ | ||
insecureSkipVerify?: boolean; | ||
keyPair?: X509KeyPair; | ||
/** | ||
* Defines the set of root certificate authority that clients use when | ||
* verifying server certificates. If not set, use the host's root CA set. | ||
*/ | ||
ca?: string; | ||
}; |
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,25 +1,43 @@ | ||
import { Header } from "./header.ts"; | ||
import { SASLConfig } from "./security/sasl.ts"; | ||
import { TLSConfig } from "./security/tls.ts"; | ||
|
||
/** A data structure representing kafka messages written to `KafkaWriter`. */ | ||
export type KafkaWriteMessage = { | ||
/** | ||
* Can be used to configured the topic if not already specified on | ||
* `KafkWriter` itself. | ||
*/ | ||
topic?: string; | ||
offset?: number; | ||
highWaterMark?: number; | ||
key?: Uint8Array; | ||
value?: Uint8Array; | ||
headers?: Header[]; | ||
/** If not set, will be automatically set when writing the message. */ | ||
time?: number; | ||
}; | ||
|
||
/** A configuration object used to create new instances of `KafkaWriter`. */ | ||
export type KafkaWriterConfig = { | ||
/** | ||
* Name of the topic that `KafkaWriter` will produce messages to. | ||
* Setting this field or not is a mutually exclusive option. If you set `topic` | ||
* here, you must not set `topic` for any `KafkaWriteMessage`. Otherwise, if you do | ||
* not set `topic`, every `KafkaWriteMessage` must have `topic` specified. | ||
*/ | ||
topic?: string; | ||
/** Address of the kafka cluster that this writer is configured to send messages to. */ | ||
address: string; | ||
/** Maximum amount of time that connections will remain open and unused. */ | ||
idleTimeout?: number; | ||
sasl?: SASLConfig; | ||
tls?: TLSConfig; | ||
}; | ||
|
||
export interface KafkaWriter { | ||
/** Writes a batch of messages to the configured kafka topic. */ | ||
writeMessages: (msgs: KafkaWriteMessage[]) => Promise<void>; | ||
/** Close flushes pending writes, and waits for all writes to complete before returning. */ | ||
close: () => Promise<void>; | ||
} |