Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions docs/admin.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,46 @@ Options:
| -------- | ------------------------------- | -------------------------------------------------------------------------------- |
| topics | `DescribeLogDirsRequestTopic[]` | Array of topics specifying the topics and partitions for which to describe logs. |

### `describeConfigs(options[, callback])`

Describes configuration parameters for specified resources.

The return value is an array of resource configurations, each containing the resource type, name, and configuration entries.

Options:

| Property | Type | Description |
| -------------------- | ---------------------------------- | ------------------------------------------------------------------------------------------ |
| resources | `DescribeConfigsRequestResource[]` | Array of resources specifying the resource type, name, and configuration keys to describe. |
| includeSynonyms | `boolean` | Whether to include configuration synonyms in the response. Defaults to `false`. |
| includeDocumentation | `boolean` | Whether to include configuration documentation in the response. Defaults to `false`. |

### `alterConfigs(options[, callback])`

Alters configuration parameters for specified resources.

The return value is `void`.

Options:

| Property | Type | Description |
| ------------ | ------------------------------- | ------------------------------------------------------------------------------------ |
| resources | `AlterConfigsRequestResource[]` | Array of resources specifying the resource type, name, and configurations to change. |
| validateOnly | `boolean` | Whether to only validate the request without applying changes. Defaults to `false`. |

### `incrementalAlterConfigs(options[, callback])`

Incrementally alters configuration parameters for specified resources using specific operations (Set, delete, append, subract).

The return value is `void`.

Options:

| Property | Type | Description |
| ------------ | ------------------------------------------ | -------------------------------------------------------------------------------------- |
| resources | `IncrementalAlterConfigsRequestResource[]` | Array of resources specifying the resource type, name, and incremental configurations. |
| validateOnly | `boolean` | Whether to only validate the request without applying changes. Defaults to `false`. |

### `close([callback])`

Closes the admin and all its connections.
Expand Down
41 changes: 21 additions & 20 deletions docs/diagnostic.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,23 +62,24 @@ Each tracing channel publishes events with the following common properties:

## Published tracing channels

| Name | Target | Description |
| ----------------------------------- | ---------------- | ------------------------------------------------------------------------------------------------- |
| `plt:kafka:connections:connects` | `Connection` | Traces a connection attempt to a broker. |
| `plt:kafka:connections:api` | `Connection` | Traces a low level API request. |
| `plt:kafka:connections:pools:gets` | `ConnectionPool` | Traces a connection retrieval attempt from a connection pool. |
| `plt:kafka:base:apis` | `Base` | Traces a `Base.listApis` request. |
| `plt:kafka:base:metadata` | `Base` | Traces a `Base.metadata` request. |
| `plt:kafka:admin:topics` | `Admin` | Traces a `Admin.createTopics` or `Admin.deleteTopics` request. |
| `plt:kafka:admin:groups` | `Admin` | Traces a `Admin.listGroups`, `Admin.describeGroups` or `Admin.deleteGroups` request. |
| `plt:kafka:admin:clientQuotas` | `Admin` | Traces a `Admin.describeClientQuotas` or `Admin.alterClientQuotas` request. |
| `plt:kafka:admin:logDirs` | `Admin` | Traces a `Admin.describeLogDirs` request. |
| `plt:kafka:producer:initIdempotent` | `Producer` | Traces a `Producer.initIdempotentProducer` request. |
| `plt:kafka:producer:sends` | `Producer` | Traces a `Producer.send` request. |
| `plt:kafka:consumer:group` | `Consumer` | Traces a `Consumer.findGroupCoordinator`, `Consumer.joinGroup` or `Consumer.leaveGroup` requests. |
| `plt:kafka:consumer:heartbeat` | `Consumer` | Traces the `Consumer` heartbeat requests. |
| `plt:kafka:consumer:receives` | `Consumer` | Traces processing of every message. |
| `plt:kafka:consumer:fetches` | `Consumer` | Traces a `Consumer.fetch` request. |
| `plt:kafka:consumer:consumes` | `Consumer` | Traces a `Consumer.consume` request. |
| `plt:kafka:consumer:commits` | `Consumer` | Traces a `Consumer.commit` request. |
| `plt:kafka:consumer:offsets` | `Consumer` | Traces a `Consumer.listOffsets` or `Consumer.listCommittedOffsets` request. |
| Name | Target | Description |
| ----------------------------------- | ---------------- | --------------------------------------------------------------------------------------------------- |
| `plt:kafka:connections:connects` | `Connection` | Traces a connection attempt to a broker. |
| `plt:kafka:connections:api` | `Connection` | Traces a low level API request. |
| `plt:kafka:connections:pools:gets` | `ConnectionPool` | Traces a connection retrieval attempt from a connection pool. |
| `plt:kafka:base:apis` | `Base` | Traces a `Base.listApis` request. |
| `plt:kafka:base:metadata` | `Base` | Traces a `Base.metadata` request. |
| `plt:kafka:admin:topics` | `Admin` | Traces a `Admin.createTopics` or `Admin.deleteTopics` request. |
| `plt:kafka:admin:groups` | `Admin` | Traces a `Admin.listGroups`, `Admin.describeGroups` or `Admin.deleteGroups` request. |
| `plt:kafka:admin:clientQuotas` | `Admin` | Traces a `Admin.describeClientQuotas` or `Admin.alterClientQuotas` request. |
| `plt:kafka:admin:logDirs` | `Admin` | Traces a `Admin.describeLogDirs` request. |
| `plt:kafka:admin:configs` | `Admin` | Traces a `Admin.describeConfigs`, `Admin.alterConfigs`, or `Admin.incrementalAlterConfigs` request. |
| `plt:kafka:producer:initIdempotent` | `Producer` | Traces a `Producer.initIdempotentProducer` request. |
| `plt:kafka:producer:sends` | `Producer` | Traces a `Producer.send` request. |
| `plt:kafka:consumer:group` | `Consumer` | Traces a `Consumer.findGroupCoordinator`, `Consumer.joinGroup` or `Consumer.leaveGroup` requests. |
| `plt:kafka:consumer:heartbeat` | `Consumer` | Traces the `Consumer` heartbeat requests. |
| `plt:kafka:consumer:receives` | `Consumer` | Traces processing of every message. |
| `plt:kafka:consumer:fetches` | `Consumer` | Traces a `Consumer.fetch` request. |
| `plt:kafka:consumer:consumes` | `Consumer` | Traces a `Consumer.consume` request. |
| `plt:kafka:consumer:commits` | `Consumer` | Traces a `Consumer.commit` request. |
| `plt:kafka:consumer:offsets` | `Consumer` | Traces a `Consumer.listOffsets` or `Consumer.listCommittedOffsets` request. |
4 changes: 2 additions & 2 deletions playground/apis/admin/config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { api as alterConfigsV2 } from '../../../src/apis/admin/alter-configs-v2.ts'
import { api as describeConfigsV4 } from '../../../src/apis/admin/describe-configs-v4.ts'
import { api as incrementalAlterConfigsV1 } from '../../../src/apis/admin/incremental-alter-configs-v1.ts'
import { IncrementalAlterConfigTypes, ResourceTypes } from '../../../src/apis/enumerations.ts'
import { IncrementalAlterConfigOperationTypes, ResourceTypes } from '../../../src/apis/enumerations.ts'
import { Connection } from '../../../src/network/connection.ts'
import { performAPICallWithRetry } from '../../utils.ts'

Expand Down Expand Up @@ -50,7 +50,7 @@ await performAPICallWithRetry('IncrementalAlterConfig', () =>
configs: [
{
name: 'compression.type',
configOperation: IncrementalAlterConfigTypes.SET,
configOperation: IncrementalAlterConfigOperationTypes.SET,
value: 'gzip'
}
]
Expand Down
7 changes: 4 additions & 3 deletions src/apis/admin/alter-configs-v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ import { type NullableString } from '../../protocol/definitions.ts'
import { type Reader } from '../../protocol/reader.ts'
import { Writer } from '../../protocol/writer.ts'
import { createAPI, type ResponseErrorWithLocation } from '../definitions.ts'
import { type ConfigResource } from '../enumerations.ts'

export interface AlterConfigsRequestConfig {
name: string
value?: NullableString
}

export interface AlterConfigsRequestResource {
resourceType: number
resourceType: ConfigResource
resourceName: string
configs: AlterConfigsRequestConfig[]
}
Expand All @@ -20,7 +21,7 @@ export type AlterConfigsRequest = Parameters<typeof createRequest>
export interface AlterConfigsResponseResult {
errorCode: number
errorMessage: NullableString
resourceType: number
resourceType: ConfigResource
resourceName: string
}

Expand Down Expand Up @@ -81,7 +82,7 @@ export function parseResponse (
return {
errorCode,
errorMessage: r.readNullableString(),
resourceType: r.readInt8(),
resourceType: r.readInt8() as ConfigResource,
resourceName: r.readString()
}
})
Expand Down
37 changes: 17 additions & 20 deletions src/apis/admin/describe-configs-v4.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,37 @@ import { type NullableString } from '../../protocol/definitions.ts'
import { type Reader } from '../../protocol/reader.ts'
import { Writer } from '../../protocol/writer.ts'
import { createAPI, type ResponseErrorWithLocation } from '../definitions.ts'
import { type ConfigSource, type ConfigResource, type ConfigType } from '../enumerations.ts'

export interface DescribeConfigsRequestResource {
resourceType: number
resourceType: ConfigResource
resourceName: string
configurationKeys: string[]
configurationKeys?: string[] | null | undefined
}

export type DescribeConfigsRequest = Parameters<typeof createRequest>

export interface DescribeConfigsResponseSynonym {
name: string
value: NullableString
source: number
source: ConfigSource
}

export interface DescribeConfigsResponseConfig {
name: string
value: NullableString
readOnly: boolean
configSource: number
configSource: ConfigSource
isSensitive: boolean
synonyms: DescribeConfigsResponseSynonym[]
configType: number
configType: ConfigType
documentation: NullableString
}

export interface DescribeConfigsResponseResult {
errorCode: number
errorMessage: NullableString
resourceType: number
resourceType: ConfigResource
resourceName: string
configs: DescribeConfigsResponseConfig[]
}
Expand Down Expand Up @@ -108,27 +109,23 @@ export function parseResponse (
return {
errorCode,
errorMessage: r.readNullableString(),
resourceType: r.readInt8(),
resourceType: r.readInt8() as ConfigResource,
resourceName: r.readString(),
configs: r.readArray(r => {
return {
name: r.readString(),
value: r.readNullableString(),
readOnly: r.readBoolean(),
configSource: r.readInt8(),
configSource: r.readInt8() as ConfigSource,
isSensitive: r.readBoolean(),
synonyms: r.readArray(
r => {
return {
name: r.readString(),
value: r.readNullableString(),
source: r.readInt8()
}
},
true,
false
),
configType: r.readInt8(),
synonyms: r.readArray(r => {
return {
name: r.readString(),
value: r.readNullableString(),
source: r.readInt8() as ConfigSource
}
}),
configType: r.readInt8() as ConfigType,
documentation: r.readNullableString()
}
})
Expand Down
30 changes: 23 additions & 7 deletions src/apis/admin/incremental-alter-configs-v1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,29 @@ import { type NullableString } from '../../protocol/definitions.ts'
import { type Reader } from '../../protocol/reader.ts'
import { Writer } from '../../protocol/writer.ts'
import { createAPI, type ResponseErrorWithLocation } from '../definitions.ts'
import {
type IncrementalAlterConfigOperationTypes,
type ConfigResource,
type IncrementalAlterConfigOperationType
} from '../enumerations.ts'

export interface IncrementalAlterConfigsRequestConfig {
Copy link
Contributor

Choose a reason for hiding this comment

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

Revert renaming this.

interface IncrementalAlterConfigsDeletionRequestConfig {
name: string
configOperation: number
value?: NullableString
configOperation: typeof IncrementalAlterConfigOperationTypes.DELETE
}

interface IncrementalAlterConfigsModificationRequestConfig {
name: string
configOperation: Exclude<IncrementalAlterConfigOperationType, typeof IncrementalAlterConfigOperationTypes.DELETE>
value: string
}

export type IncrementalAlterConfigsRequestConfig =
| IncrementalAlterConfigsModificationRequestConfig
| IncrementalAlterConfigsDeletionRequestConfig

export interface IncrementalAlterConfigsRequestResource {
resourceType: number
resourceType: ConfigResource
resourceName: string
configs: IncrementalAlterConfigsRequestConfig[]
}
Expand All @@ -21,7 +35,7 @@ export type IncrementalAlterConfigsRequest = Parameters<typeof createRequest>
export interface IncrementalAlterConfigsResponseResult {
errorCode: number
errorMessage: NullableString
resourceType: number
resourceType: ConfigResource
resourceName: string
}

Expand All @@ -47,7 +61,9 @@ export function createRequest (resources: IncrementalAlterConfigsRequestResource
w.appendInt8(r.resourceType)
.appendString(r.resourceName)
.appendArray(r.configs, (w, r) => {
w.appendString(r.name).appendInt8(r.configOperation).appendString(r.value)
w.appendString(r.name)
.appendInt8(r.configOperation)
.appendString((r as IncrementalAlterConfigsModificationRequestConfig).value)
})
})
.appendBoolean(validateOnly)
Expand Down Expand Up @@ -83,7 +99,7 @@ export function parseResponse (
return {
errorCode,
errorMessage: r.readNullableString(),
resourceType: r.readInt8(),
resourceType: r.readInt8() as ConfigResource,
resourceName: r.readString()
}
})
Expand Down
33 changes: 26 additions & 7 deletions src/apis/enumerations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,20 +83,39 @@ export const ConfigSources = {
DYNAMIC_DEFAULT_BROKER_CONFIG: 3,
STATIC_BROKER_CONFIG: 4,
DEFAULT_CONFIG: 5,
DYNAMIC_BROKER_LOGGER_CONFIG: 6
DYNAMIC_BROKER_LOGGER_CONFIG: 6,
CLIENT_METRICS_CONFIG: 7,
GROUP_CONFIG: 8
} as const
export type ConfigSource = keyof typeof ConfigSources
export type ConfigSource = (typeof ConfigSources)[keyof typeof ConfigSources]
Copy link
Contributor

Choose a reason for hiding this comment

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

Revert this.


export const ConfigTypes = {
export const ConfigResources = {
UNKNOWN: 0,
TOPIC: 2,
BROKER: 4,
BROKER_LOGGER: 8
BROKER_LOGGER: 8,
CLIENT_METRICS: 16,
GROUP: 32
} as const
export type ConfigResource = (typeof ConfigResources)[keyof typeof ConfigResources]

export const ConfigTypes = {
UNKNOWN: 0,
BOOLEAN: 1,
STRING: 2,
INT: 3,
SHORT: 4,
LONG: 5,
DOUBLE: 6,
LIST: 7,
CLASS: 8,
PASSWORD: 9
} as const
export type ConfigType = keyof typeof ConfigTypes
export type ConfigType = (typeof ConfigTypes)[keyof typeof ConfigTypes]
Copy link
Contributor

Choose a reason for hiding this comment

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

export type ConfigType = keyof typeof ConfigTypes


export const IncrementalAlterConfigTypes = { SET: 0, DELETE: 1, APPEND: 2, SUBTRACT: 3 }
export type IncrementalAlterConfigType = keyof typeof IncrementalAlterConfigTypes
export const IncrementalAlterConfigOperationTypes = { SET: 0, DELETE: 1, APPEND: 2, SUBTRACT: 3 } as const
export type IncrementalAlterConfigOperationType =
(typeof IncrementalAlterConfigOperationTypes)[keyof typeof IncrementalAlterConfigOperationTypes]
Copy link
Contributor

Choose a reason for hiding this comment

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

Revert this


// ./admin/*-client-quotas.ts
export const ClientQuotaMatchTypes = { EXACT: 0, DEFAULT: 1, ANY: 2 } as const
Expand Down
Loading