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

Restructure _BaseCallHandler et al. for interceptors #1028

Merged

Conversation

glbrntt
Copy link
Collaborator

@glbrntt glbrntt commented Nov 3, 2020

Motivation:

The state management in _BaseCallHandler and its associated subclasses
is a little handwavy and somewhat implicit. To support server
interceptors we need a stronger idea of the state of the call.

Modifications:

  • Refactor _BaseCallHandler to have an explicit state machine and hold
    an interceptor pipeline. This is the 'main' state machine. Each
    subclass also has its own down state machine holding state relating to
    the event observer and observer context. Most of the logic shared between
    the state machines is very similar, it may be beneficial to abstract
    some of this away in the future.
  • Add head and tail interceptors.
  • Wire through interceptors from the call handler factory (much like the
    client, generated server code will have its own interceptor factory
    which will pass interceptors to the call handler factory).

Result:

  • Server interceptors (minus codegen)

Motivation:

The state management in `_BaseCallHandler` and its associated subclasses
is a little handwavy and somewhat implicit. To support server
interceptors we need a stronger idea of the state of the call.

Modifications:

- Refactor `_BaseCallHandler` to have an explicit state machine and hold
  an interceptor pipeline. This is the 'main' state machine. Each
  subclass also has its own down state machine holding state relating to
  the event observer and observer context. Most of the logic shared between
  the state machines is very similar, it may be beneficial to abstract
  some of this away in the future.
- Add head and tail interceptors.
- Wire through interceptors from the call handler factory (much like the
  client, generated server code will have its own interceptor factory
  which will pass interceptors to the call handler factory).

Result:

- Server interceptors (minus codegen)
@glbrntt glbrntt added the ⚠️ semver/major Breaks existing public API. label Nov 3, 2020
@glbrntt glbrntt requested a review from Lukasa November 3, 2020 14:43
Copy link
Collaborator

@Lukasa Lukasa left a comment

Choose a reason for hiding this comment

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

LGTM.

@glbrntt glbrntt merged commit 82e00be into grpc:gb-feature-interceptors Nov 4, 2020
@glbrntt glbrntt deleted the gb-server-interceptors branch November 4, 2020 08:43
glbrntt added a commit that referenced this pull request Nov 6, 2020
Motivation:

The state management in `_BaseCallHandler` and its associated subclasses
is a little handwavy and somewhat implicit. To support server
interceptors we need a stronger idea of the state of the call.

Modifications:

- Refactor `_BaseCallHandler` to have an explicit state machine and hold
  an interceptor pipeline. This is the 'main' state machine. Each
  subclass also has its own down state machine holding state relating to
  the event observer and observer context. Most of the logic shared between
  the state machines is very similar, it may be beneficial to abstract
  some of this away in the future.
- Add head and tail interceptors.
- Wire through interceptors from the call handler factory (much like the
  client, generated server code will have its own interceptor factory
  which will pass interceptors to the call handler factory).

Result:

- Server interceptors (minus codegen)
glbrntt added a commit that referenced this pull request Nov 12, 2020
Motivation:

The state management in `_BaseCallHandler` and its associated subclasses
is a little handwavy and somewhat implicit. To support server
interceptors we need a stronger idea of the state of the call.

Modifications:

- Refactor `_BaseCallHandler` to have an explicit state machine and hold
  an interceptor pipeline. This is the 'main' state machine. Each
  subclass also has its own down state machine holding state relating to
  the event observer and observer context. Most of the logic shared between
  the state machines is very similar, it may be beneficial to abstract
  some of this away in the future.
- Add head and tail interceptors.
- Wire through interceptors from the call handler factory (much like the
  client, generated server code will have its own interceptor factory
  which will pass interceptors to the call handler factory).

Result:

- Server interceptors (minus codegen)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⚠️ semver/major Breaks existing public API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants