Skip to content

Commit d82cf43

Browse files
General cleanup and switching of library name to gorealconf
1 parent 904f9a0 commit d82cf43

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1891
-1889
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ A clear description of what you expected to happen.
2020

2121
**Environment:**
2222
- Go version:
23-
- DynConf version:
23+
- gorealconf version:
2424
- OS:
2525
- Dependencies versions (etcd/consul/redis if applicable):
2626

README.md

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
# DynConf
1+
# gorealconf
22

3-
[![Go Reference](https://pkg.go.dev/badge/github.com/samuelarogbonlo/dynconf.svg)](https://pkg.go.dev/github.com/samuelarogbonlo/dynconf)
4-
[![Build Status](https://github.com/samuelarogbonlo/dynconf/workflows/CI/badge.svg)](https://github.com/samuelarogbonlo/dynconf/actions)
5-
[![Go Report Card](https://goreportcard.com/badge/github.com/samuelarogbonlo/dynconf)](https://goreportcard.com/report/github.com/samuelarogbonlo/dynconf)
6-
[![codecov](https://codecov.io/gh/samuelarogbonlo/dynconf/branch/main/graph/badge.svg)](https://codecov.io/gh/samuelarogbonlo/dynconf)
3+
[![Go Reference](https://pkg.go.dev/badge/github.com/samuelarogbonlo/gorealconf.svg)](https://pkg.go.dev/github.com/samuelarogbonlo/gorealconf)
4+
[![Build Status](https://github.com/samuelarogbonlo/gorealconf/workflows/CI/badge.svg)](https://github.com/samuelarogbonlo/gorealconf/actions)
5+
[![Go Report Card](https://goreportcard.com/badge/github.com/samuelarogbonlo/gorealconf)](https://goreportcard.com/report/github.com/samuelarogbonlo/gorealconf)
6+
[![codecov](https://codecov.io/gh/samuelarogbonlo/gorealconf/branch/main/graph/badge.svg)](https://codecov.io/gh/samuelarogbonlo/gorealconf)
77

8-
DynConf is a type-safe dynamic configuration management library for Go applications.
8+
gorealconf is a type-safe dynamic configuration management library for Go applications.
99

1010
## Installation
1111

1212
Latest version:
1313
```bash
14-
go get github.com/samuelarogbonlo/dynconf
14+
go get github.com/samuelarogbonlo/gorealconf
1515
```
1616

1717
Specific version:
1818
```bash
19-
go get github.com/samuelarogbonlo/dynconf@v0.1.0
19+
go get github.com/samuelarogbonlo/gorealconf@v0.1.0
2020
```
2121

2222
## Quick Start
@@ -31,11 +31,11 @@ type AppConfig struct {
3131

3232
2. Create and use configuration:
3333
```go
34-
cfg := dynconf.New[AppConfig]()
34+
cfg := gorealconf.New[AppConfig]()
3535

3636
// Add validation
37-
cfg = dynconf.New[AppConfig](
38-
dynconf.WithValidation[AppConfig](func(old, new AppConfig) error {
37+
cfg = gorealconf.New[AppConfig](
38+
gorealconf.WithValidation[AppConfig](func(old, new AppConfig) error {
3939
if new.ServerPort < 1024 {
4040
return errors.New("port must be >= 1024")
4141
}
@@ -60,35 +60,35 @@ type Config struct {
6060
Port int `json:"port"`
6161
Timeout time.Duration `json:"timeout"`
6262
}
63-
cfg := dynconf.New[Config]()
63+
cfg := gorealconf.New[Config]()
6464
```
6565

6666
### Multiple Configuration Sources
6767
```go
68-
cfg := dynconf.New[Config](
69-
dynconf.WithSource(fileSource),
70-
dynconf.WithSource(etcdSource),
68+
cfg := gorealconf.New[Config](
69+
gorealconf.WithSource(fileSource),
70+
gorealconf.WithSource(etcdSource),
7171
)
7272
```
7373

7474
### Automatic Validation & Rollback
7575
```go
76-
cfg := dynconf.New[Config](
77-
dynconf.WithValidation[Config](validateConfig),
78-
dynconf.WithRollback[Config](true),
76+
cfg := gorealconf.New[Config](
77+
gorealconf.WithValidation[Config](validateConfig),
78+
gorealconf.WithRollback[Config](true),
7979
)
8080
```
8181

8282
### Gradual Rollouts
8383
```go
84-
strategy := dynconf.NewPercentageStrategy(10)
85-
rollout := dynconf.NewRollout[Config](cfg).
84+
strategy := gorealconf.NewPercentageStrategy(10)
85+
rollout := gorealconf.NewRollout[Config](cfg).
8686
WithStrategy(strategy)
8787
```
8888

8989
### Metrics Integration
9090
```go
91-
metrics := dynconf.NewMetrics("myapp")
91+
metrics := gorealconf.NewMetrics("myapp")
9292
cfg.WithMetrics(metrics)
9393
```
9494

cmd/examples/basic/main.go

Lines changed: 53 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,70 @@
11
package main
22

33
import (
4-
"context"
5-
"errors"
6-
"log"
7-
"os"
8-
"os/signal"
9-
"syscall"
10-
"time"
4+
"context"
5+
"errors"
6+
"log"
7+
"os"
8+
"os/signal"
9+
"syscall"
10+
"time"
1111

12-
"github.com/samuelarogbonlo/dynconf/pkg/dynconf"
12+
"github.com/samuelarogbonlo/gorealconf/pkg/gorealconf"
1313
)
1414

1515
type AppConfig struct {
16-
ServerPort int `json:"server_port"`
17-
Timeout time.Duration `json:"timeout"`
16+
ServerPort int `json:"server_port"`
17+
Timeout time.Duration `json:"timeout"`
1818
}
1919

2020
func main() {
21-
// Create a cancellable context
22-
ctx, cancel := context.WithCancel(context.Background())
23-
defer cancel()
21+
// Create a cancellable context
22+
ctx, cancel := context.WithCancel(context.Background())
23+
defer cancel()
2424

25-
cfg := dynconf.New[AppConfig](
26-
dynconf.WithValidation[AppConfig](func(old, new AppConfig) error {
27-
if new.ServerPort < 1024 {
28-
return errors.New("server port must be >= 1024")
29-
}
30-
return nil
31-
}),
32-
dynconf.WithRollback[AppConfig](true),
33-
)
25+
cfg := gorealconf.New[AppConfig](
26+
gorealconf.WithValidation[AppConfig](func(old, new AppConfig) error {
27+
if new.ServerPort < 1024 {
28+
return errors.New("server port must be >= 1024")
29+
}
30+
return nil
31+
}),
32+
gorealconf.WithRollback[AppConfig](true),
33+
)
3434

35-
// Initialize configuration
36-
initialConfig := AppConfig{
37-
ServerPort: 8080,
38-
Timeout: 5 * time.Second,
39-
}
35+
// Initialize configuration
36+
initialConfig := AppConfig{
37+
ServerPort: 8080,
38+
Timeout: 5 * time.Second,
39+
}
4040

41-
if err := cfg.Update(ctx, initialConfig); err != nil {
42-
log.Fatal(err)
43-
}
41+
if err := cfg.Update(ctx, initialConfig); err != nil {
42+
log.Fatal(err)
43+
}
4444

45-
// Setup signal handling for graceful shutdown
46-
sigChan := make(chan os.Signal, 1)
47-
signal.Notify(sigChan, syscall.SIGINT, syscall.SIGTERM)
45+
// Setup signal handling for graceful shutdown
46+
sigChan := make(chan os.Signal, 1)
47+
signal.Notify(sigChan, syscall.SIGINT, syscall.SIGTERM)
4848

49-
// Watch for changes
50-
changes, err := cfg.Watch(ctx)
51-
if err != nil {
52-
log.Fatal(err)
53-
}
49+
// Watch for changes
50+
changes, err := cfg.Watch(ctx)
51+
if err != nil {
52+
log.Fatal(err)
53+
}
5454

55-
// Handle configuration updates
56-
go func() {
57-
for {
58-
select {
59-
case newCfg := <-changes:
60-
log.Printf("Config updated: %+v", newCfg)
61-
case <-ctx.Done():
62-
return
63-
}
64-
}
65-
}()
55+
// Handle configuration updates
56+
go func() {
57+
for {
58+
select {
59+
case newCfg := <-changes:
60+
log.Printf("Config updated: %+v", newCfg)
61+
case <-ctx.Done():
62+
return
63+
}
64+
}
65+
}()
6666

67-
// Wait for shutdown signal
68-
sig := <-sigChan
69-
log.Printf("Received signal %v, shutting down", sig)
70-
}
67+
// Wait for shutdown signal
68+
sig := <-sigChan
69+
log.Printf("Received signal %v, shutting down", sig)
70+
}

0 commit comments

Comments
 (0)