@rivascva/dt-idl 1.1.175 → 1.1.177

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -36,9 +36,13 @@ type BaseRDB struct {
36
36
  database string
37
37
  }
38
38
 
39
- func NewBaseRDB(address string, service string) RDB {
39
+ func NewBaseRDB(address string, username string, password string, service string) RDB {
40
40
  //exhaustruct:ignore - other fields are optional
41
- client := goredis.NewClient(&goredis.Options{Addr: address})
41
+ client := goredis.NewClient(&goredis.Options{
42
+ Addr: address,
43
+ Username: username,
44
+ Password: password,
45
+ })
42
46
  return &BaseRDB{
43
47
  client: client,
44
48
  database: service,
package/go/srv/srv.go ADDED
@@ -0,0 +1,45 @@
1
+ package srv
2
+
3
+ import (
4
+ "context"
5
+ "errors"
6
+ "fmt"
7
+ "net/http"
8
+ "time"
9
+
10
+ "github.com/RivasCVA/dt-idl/go/log"
11
+ "github.com/RivasCVA/dt-idl/go/utils"
12
+ )
13
+
14
+ // ListenAndServe starts the HTTP server and blocks until the context is cancelled.
15
+ // It then gracefully shuts down allowing in-flight requests to complete.
16
+ // The onShutdown functions are called after the server stops to clean up resources.
17
+ func ListenAndServe(ctx context.Context, log log.Logger, srv *http.Server, onShutdown []func()) {
18
+ // start the server in a separate goroutine
19
+ go func() {
20
+ log.Info(ctx, fmt.Sprintf("server running on %s", srv.Addr))
21
+ if err := srv.ListenAndServe(); err != nil && !errors.Is(err, http.ErrServerClosed) {
22
+ log.Error(ctx, err)
23
+ }
24
+ }()
25
+
26
+ // wait for the context to be cancelled
27
+ <-ctx.Done()
28
+ log.Info(ctx, "shutting down gracefully...")
29
+
30
+ // give in-flight requests time to complete
31
+ shutdownCtx, cancel := utils.DetachContext(ctx, 10*time.Second)
32
+ defer cancel()
33
+
34
+ // shutdown the server
35
+ if err := srv.Shutdown(shutdownCtx); err != nil {
36
+ log.Error(ctx, err)
37
+ }
38
+
39
+ // run cleanup functions
40
+ for _, fn := range onShutdown {
41
+ fn()
42
+ }
43
+
44
+ log.Info(ctx, "server stopped")
45
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rivascva/dt-idl",
3
- "version": "1.1.175",
3
+ "version": "1.1.177",
4
4
  "description": "Dream Trade - Interface Definition Language",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",