-
Notifications
You must be signed in to change notification settings - Fork 308
Add the Lease Proxy Server implementation #4961
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
Changes from all commits
7e037d2
7884b8a
807cdef
02990fc
69a6390
e9347de
be7b976
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,23 +11,25 @@ import ( | |
| ) | ||
|
|
||
| type fakeClient struct { | ||
| owner string | ||
| failures map[string]error | ||
| calls *[]string | ||
| owner string | ||
| failures map[string]error | ||
| calls *[]string | ||
| resources map[string]*common.Resource | ||
| } | ||
|
|
||
| func NewFakeClient(owner, url string, retries int, failures map[string]error, calls *[]string) Client { | ||
| func NewFakeClient(owner, url string, retries int, failures map[string]error, calls *[]string, resources map[string]*common.Resource) Client { | ||
| if calls == nil { | ||
| calls = &[]string{} | ||
| } | ||
| randId = func() string { | ||
| return "random" | ||
| if resources == nil { | ||
| resources = make(map[string]*common.Resource) | ||
| } | ||
| return newClient(&fakeClient{ | ||
| owner: owner, | ||
| failures: failures, | ||
| calls: calls, | ||
| }, retries, time.Duration(0)) | ||
| owner: owner, | ||
| failures: failures, | ||
| calls: calls, | ||
| resources: resources, | ||
| }, retries, time.Duration(0), WithRandID(func() string { return "random" })) | ||
| } | ||
|
|
||
| func (c *fakeClient) addCall(call string, args ...string) error { | ||
|
|
@@ -44,11 +46,17 @@ func (c *fakeClient) addCall(call string, args ...string) error { | |
|
|
||
| func (c *fakeClient) AcquireWaitWithPriority(ctx context.Context, rtype, state, dest, requestID string) (*common.Resource, error) { | ||
| err := c.addCall("acquireWaitWithPriority", rtype, state, dest, requestID) | ||
| if res, ok := c.resources[fmt.Sprintf("acquireWaitWithPriority_%s_%s_%s_%s", rtype, state, dest, requestID)]; ok { | ||
| return res, nil | ||
| } | ||
| return &common.Resource{Name: fmt.Sprintf("%s_%d", rtype, len(*c.calls)-1)}, err | ||
| } | ||
|
|
||
| func (c *fakeClient) Acquire(rtype, state, dest string) (*common.Resource, error) { | ||
| err := c.addCall("acquire", rtype, state, dest) | ||
| if res, ok := c.resources[fmt.Sprintf("acquire_%s_%s_%s", rtype, state, dest)]; ok { | ||
| return res, nil | ||
| } | ||
| return &common.Resource{Name: fmt.Sprintf("%s_%d", rtype, len(*c.calls)-1)}, err | ||
|
Comment on lines
47
to
60
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Preserve injected failures even when a predefined resource exists.
🛠️ Suggested fix if res, ok := c.resources[fmt.Sprintf("acquireWaitWithPriority_%s_%s_%s_%s", rtype, state, dest, requestID)]; ok {
- return res, nil
+ return res, err
}
@@
if res, ok := c.resources[fmt.Sprintf("acquire_%s_%s_%s", rtype, state, dest)]; ok {
- return res, nil
+ return res, err
}🤖 Prompt for AI Agents
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't want to address this issue in this PR There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.