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

[GoSDK] Is there any way to add parent context to the request? #171

Open
bearaujus opened this issue Nov 16, 2024 · 0 comments
Open

[GoSDK] Is there any way to add parent context to the request? #171

bearaujus opened this issue Nov 16, 2024 · 0 comments

Comments

@bearaujus
Copy link

bearaujus commented Nov 16, 2024

So if I have:

ctx := context.TODO()

How to add that context to this function?

req := &ram.ListPoliciesRequest{
	Marker:     marker,
	MaxItems:   &maxItems,
	PolicyType: &policyType,
}

// TODO: find a way to add parent context to the request
resp, err := ramClient.ListPoliciesWithOptions(req, &utils.RuntimeOptions{})
if err != nil {
	return nil, err
}

So my objective is, when the parent context is meet the deadline, it will also cancelled the request. So it will not blocking.

What I'm expecting is looks like this:

req := &ram.ListPoliciesRequest{
	Marker:     marker,
	MaxItems:   &maxItems,
	PolicyType: &policyType,
}

// TODO: find a way to add parent context to the request
resp, err := ramClient.ListPoliciesWithOptions(HERE-> ctx, req, &utils.RuntimeOptions{})
if err != nil {
	return nil, err
}

Or I'm expecting to be able to add the context to the RuntimeOptions. But I have no clue for it.

Any workaround for this?

Fyi:
The ramClient on this example is from "github.com/alibabacloud-go/ram-20150501/v2/client"

@bearaujus bearaujus changed the title [GoSDK] Is there any way to add parrent context to the request? [GoSDK] Is there any way to add parent context to the request? Nov 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant