Skip to content

Commit

Permalink
CI correction with basic changes
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelarogbonlo committed Jan 21, 2025
1 parent 32999ab commit 00113f2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
Binary file added basic
Binary file not shown.
27 changes: 18 additions & 9 deletions cmd/examples/basic/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package main

import (
"context"
"errors" // Added this import
"errors"
"log"
"time"

Expand All @@ -27,18 +27,27 @@ func main() {
dynconf.WithRollback[AppConfig](true),
)

// You might need to use Subscribe() instead of Watch() depending on the package version
changes, err := cfg.Subscribe(ctx) // Changed Watch to Subscribe
if err != nil {
log.Fatal(err) // This directly handles the error from Subscribe
}
// Initialize with a default configuration
initialConfig := AppConfig{
ServerPort: 8080,
Timeout: 5 * time.Second,
}

if err := cfg.Update(ctx, initialConfig); err != nil {
log.Fatal(err)
}

// Subscribe to changes - get both the channel and cleanup function
changes, cleanup := cfg.Subscribe(ctx)
defer cleanup() // Ensure cleanup is called when main exits

// Handle configuration updates in a separate goroutine
go func() {
for newCfg := range changes {
log.Printf("Config updated: %+v", newCfg)
for update := range changes {
log.Printf("Config updated: %+v", update)
}
}()

// Application logic...
// Keep the application running
select {}
}

0 comments on commit 00113f2

Please sign in to comment.