@rivascva/dt-idl 1.1.177 → 1.1.178

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.
@@ -4,6 +4,8 @@ import (
4
4
  "context"
5
5
  "errors"
6
6
  "fmt"
7
+ "os/signal"
8
+ "syscall"
7
9
  "time"
8
10
 
9
11
  "github.com/RivasCVA/dt-idl/go/models"
@@ -90,3 +92,10 @@ func GetRequestIdFromContext(ctx context.Context) (string, error) {
90
92
  func DetachContext(ctx context.Context, timeout time.Duration) (context.Context, context.CancelFunc) {
91
93
  return context.WithTimeout(context.WithoutCancel(ctx), timeout)
92
94
  }
95
+
96
+ // NewServerContext returns a new context that is canceled when the server receives an interrupt or kill signal.
97
+ // The context is returned along with a cancel function that can be used to cancel the context manually.
98
+ // It is recommended to use this context as the base context for a server and defer the cancel function.
99
+ func NewServerContext() (context.Context, context.CancelFunc) {
100
+ return signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
101
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rivascva/dt-idl",
3
- "version": "1.1.177",
3
+ "version": "1.1.178",
4
4
  "description": "Dream Trade - Interface Definition Language",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",