Skip to content

Commit

Permalink
specgen docs (#232)
Browse files Browse the repository at this point in the history
  • Loading branch information
hariso authored Jan 9, 2025
1 parent f9cb8f7 commit fbe301d
Showing 1 changed file with 43 additions and 2 deletions.
45 changes: 43 additions & 2 deletions specgen/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,44 @@
# Specgen
# specgen

TBD
## Overview

`specgen` is a tool that generates connector specifications and writes them to a
`connector.yaml`. The input to `specgen` are source and destination
configuration structs returned by the `Config()` methods in the connectors.

`specgen` is run as part of `go generate`. It also needs access to the
`sdk.Connector` variable that holds references to constructor functions for the
source and the destination, so it's best to place it in the `connector.go` file.
The following is an example from the Kafka connector:

```go
//go:generate specgen

// Package kafka contains implementations for Kafka source and destination
// connectors for Conduit.
package kafka

import (
_ "embed"

sdk "github.com/conduitio/conduit-connector-sdk"
)

//go:embed connector.yaml
var specs string

var Connector = sdk.Connector{
NewSpecification: sdk.YAMLSpecification(specs),
NewSource: NewSource,
NewDestination: NewDestination,
}
```

`specgen` generates the specification in the following phases:

1. Extracts the specifications from the source and destination configuration
struct.
2. Combines the extracted specification with the existing one in `connector.yaml`.

More detailed information about `specgen` and `connector.yaml` can be found in
the [Conduit documentation](https://conduit.io/docs/developing/connectors/connector-specification).

0 comments on commit fbe301d

Please sign in to comment.