Add context.Context parameter to all API methods
Enable request timeout and cancellation control by adding context.Context as the first parameter to all SDK API methods. This allows users to: - Set per-request timeouts - Cancel in-flight requests - Pass request-scoped values
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"git.dragonchain.com/dragonchain/dragonchain-prime-sdk-go/client"
|
||||
"git.dragonchain.com/dragonchain/dragonchain-prime-sdk-go/models"
|
||||
)
|
||||
@@ -13,13 +15,13 @@ func NewSystemClient(c *client.Client) *SystemClient {
|
||||
return &SystemClient{client: c}
|
||||
}
|
||||
|
||||
func (sc *SystemClient) Health() error {
|
||||
return sc.client.Get("/api/v1/health", nil)
|
||||
func (sc *SystemClient) Health(ctx context.Context) error {
|
||||
return sc.client.Get(ctx, "/api/v1/health", nil)
|
||||
}
|
||||
|
||||
func (sc *SystemClient) Status() (*models.SystemStatus, error) {
|
||||
func (sc *SystemClient) Status(ctx context.Context) (*models.SystemStatus, error) {
|
||||
var resp models.SystemStatus
|
||||
err := sc.client.Get("/api/v1/status", &resp)
|
||||
err := sc.client.Get(ctx, "/api/v1/status", &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user