Skip to content
Merged
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
13 changes: 8 additions & 5 deletions docs/_sidebar.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
- [Quick Start](getting-started/quickstart.md)

- Modules
- [Std Modules](modules/std.md)
- [Orm](modules/orm.md)
- [Swagger](modules/swagger.md)
- [New Relic](modules/newrelic.md)
- [Client](modules/client.md)
- [Kafka](modules/kafka.md)
- [Couchbase](modules/couchbase.md)
- [Kafka](modules/kafka.md)
- [New Relic](modules/newrelic.md)
- [ORM](modules/orm.md)
- [OTEL](modules/otel.md)
- [Server](modules/server.md)
- [Standard Modules](modules/std.md)
- [Swagger](modules/swagger.md)
101 changes: 101 additions & 0 deletions docs/modules/couchbase.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# Couchbase Module

The Couchbase module integrates Couchbase database support into Chaki applications, providing a configured *gocb.Cluster instance, health probes, and tracing capabilities.

## Usage

Add the module to your Chaki app, optionally with custom options:

```go
app.Use(couchbase.Module(
couchbase.WithTracer(/* custom tracer */),
couchbase.WithClusterOptionWrapper(/* wrapper func */),
))
```

The module provides a *gocb.Cluster for injection into repositories or services.

## Configuration

Configure the Couchbase connection and timeouts via YAML. Defaults are provided for timeouts.

Example (as provided):

```yaml
couchbase:
host: "couchbase://127.0.0.1"
bucketname: "Bucketname"
connecttimeout: "5000ms"
username: ${secret:couchbaseUsername}
password: ${secret:couchbasePassword}
```

Full configuration options (with defaults):

- host: "" (required, e.g., "couchbase://localhost")
- username: "" (required)
- password: "" (required)
- connecttimeout: "1000ms"
- kvtimeout: "2500ms"
- kvdurabletimeout: "10000ms"
- kvscantimeout: "10000ms"
- viewtimeout: "75000ms"
- querytimeout: "75000ms"
- analyticstimeout: "75000ms"
- searchtimeout: "75000ms"
- managmenttimeout: "75000ms"
Copy link

Copilot AI Aug 16, 2025

Choose a reason for hiding this comment

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

The configuration key 'managmenttimeout' contains a spelling error. It should be 'managementtimeout' (missing 'e').

Suggested change
- managmenttimeout: "75000ms"
- managementtimeout: "75000ms"

Copilot uses AI. Check for mistakes.

Secrets can be referenced as shown for username and password.

## Features

### Health Probes

Automatically provides liveness and readiness probes using cluster.Ping(). Implements health.Probe interface.

### Tracing

Supports multiple gocb.RequestTracer via WithTracer option. Use couchbase.ParentSpan(ctx) for request parent spans. Joined tracers are supported for combining multiple tracers.

### Cluster Options Wrappers

Customize gocb.ClusterOptions using WithClusterOptionWrapper to wrap and modify the options before connecting.

## Example

From the example/withcouchbase:

```go
// main.go
app := chaki.New()
app.Use(
server.Module(),
couchbase.Module(),
)
app.Provide(
NewRepository,
newController,
)
```

```go
// repository.go
type fooRepository struct {
coll *gocb.Collection
}

func NewRepository(cluster *gocb.Cluster, cfg *config.Config) FooRepository {
return &fooRepository{
coll: cluster.Bucket(cfg.GetString("couchbase.bucketname")).DefaultCollection(),
}
}

func (r *fooRepository) Get(ctx context.Context, id string) (*Foo, error) {
resp, err := r.coll.Get(id, &gocb.GetOptions{
ParentSpan: couchbase.ParentSpan(ctx), // Enable tracing
})
// ...
}
```

For more details, see module.go, config.go, option.go, and util.go.
7 changes: 0 additions & 7 deletions docs/modules/kafka.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,3 @@ func (c *Consumer) Consume(ctx context.Context, msg *consumer.Message) error {
}

```







23 changes: 23 additions & 0 deletions docs/modules/otel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# OTEL Module

The OTEL module provides OpenTelemetry integration for tracing and metrics in Chaki applications.

## Submodules

- **Client**: Tracing for HTTP clients.
- **Server**: Tracing for HTTP servers.
- **Kafka**: Tracing for Kafka producers and consumers.

## Usage

```go
app.Use(otel.Module(
otelclient.WithClient(),
otelserver.WithServer(),
otelkafka.WithKafka(),
))
```

Have to provide an otel init function that initiates your otel exporting mechanism

See option.go for more details.
Loading