Skip to content

Conversation

LiteSun
Copy link
Contributor

@LiteSun LiteSun commented Oct 9, 2025

Description

Separate inline upstream in apisix backend as discussed in #319

Checklist

  • I have explained the need for this PR and the problem it solves
  • I have explained the changes or the new features added to this PR
  • I have added tests corresponding to this change
  • I have updated the documentation to reflect this change
  • I have verified that this change is backward compatible

@CLAassistant
Copy link

CLAassistant commented Oct 9, 2025

CLA assistant check
All committers have signed the CLA.

@LiteSun LiteSun changed the title fix: handle service creation with upstreams fix(apisix): handle inline upstream update and delete Oct 9, 2025
@LiteSun LiteSun changed the title fix(apisix): handle inline upstream update and delete feat(apisix): separate inline upstream Oct 10, 2025
@LiteSun LiteSun marked this pull request as ready for review October 10, 2025 07:06
@LiteSun LiteSun requested a review from bzp2010 as a code owner October 10, 2025 07:06
@LiteSun LiteSun force-pushed the sy/inline-upstream branch from d36ec42 to b7d3d36 Compare October 10, 2025 14:49
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please ensure that code is always formatted by Prettier and avoid making changes that serve no practical purpose.

this.subject = opts.eventSubject;
}

private operate(event: ADCSDK.Event) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that service is a special case, creating an operateService function for it is a better choice. Let other resources continue using the simple operate function, while services with specific upstream expansion logic use a separate function.

private operate(event: ADCSDK.Event) {
   // keep original codes
}

// handle only event for service
private operateService(event: ADCSDK.event) {
  const operateWithRetry = (op) => defer(op).pipe(retry({count: 3, delay: 100/* or fn */}));
  if (event.type === ADCSDK.EventType.DELETE) {
    return from([() => this.client.delete("/apisix/admin/services/xxx"), () => this.client.delete("/apisix/admin/upstreams/xxx")]).pipe(
      concatMap((op) => operateWithRetry(op))
    )
  } else {
    return from([() => this.client.put("/apisix/admin/upstreams/xxx"), () => this.client.put("/apisix/admin/services/xxx")]).pipe(
      concatMap((op) => operateWithRetry(op))
    )
  }
}

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

Successfully merging this pull request may close these issues.

3 participants