Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

context.Context parameter missing from methods #124

Open
vniche opened this issue Sep 10, 2022 · 2 comments
Open

context.Context parameter missing from methods #124

vniche opened this issue Sep 10, 2022 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@vniche
Copy link
Contributor

vniche commented Sep 10, 2022

All methods that spawns a request to a remote service/API or have an inter process communication should (it is strongly recommended for reliability) have a context.Context as a parameters (preferably the first one). Golang context package overview:

Package context defines the Context type, which carries deadlines, cancellation signals, and other request-scoped values across API boundaries and between processes.

For example:

import (
    "context"
    "time"
  
    "github.com/Kucoin/kucoin-go-sdk"
)

kucoinClient := kucoin.NewApiService()

ctx, cancel := context.WithTimeout(context.Background, 5 * time.Second)
defer cancel()

_, _ = kucoinClient.Accounts(ctx, "", "")

_, _ = kucoinClient.Prices(ctx, "", "")

That way, if the context is canceled by either client or server (due to timeout - client-defined or gateway-defined - for example) such behavior is propagated throughout all peers.

@iamalanal
Copy link
Collaborator

Is the issue solved?

@iamalanal iamalanal added the question Further information is requested label Jul 24, 2024
@ISAAC-XXYYZZ ISAAC-XXYYZZ self-assigned this Jul 29, 2024
@ISAAC-XXYYZZ ISAAC-XXYYZZ added enhancement New feature or request and removed question Further information is requested labels Jul 29, 2024
@ISAAC-XXYYZZ
Copy link
Contributor

Thank you for your suggestion. This is indeed a great idea. We will include this feature in future API iterations. Let's stay in touch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants