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

refact: use protoreflect to convert check request v3 #631

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

regeda
Copy link
Contributor

@regeda regeda commented Jan 4, 2025

The plugin transforms a CheckRequest into OPA's input in two steps:

  1. protojson.Marshal
  2. json.Unmarshal

Since CheckRequest is a protobuf type, OPA's input can also be generated using protobuf reflection.

Benchmark results.

goos: darwin
goarch: arm64
pkg: github.com/open-policy-agent/opa-envoy-plugin/internal
cpu: Apple M2 Pro

Using JSON as the intermediate format:

BenchmarkCheck-12          10000            116460 ns/op           87881 B/op       1734 allocs/op

Using protobuf reflection:

BenchmarkCheck-12          10000            103498 ns/op           80146 B/op       1592 allocs/op

@regeda regeda force-pushed the use-protoreflect-for-input branch 7 times, most recently from 2d2f2ac to d3188d7 Compare January 4, 2025 18:00
Copy link
Collaborator

@srenatus srenatus left a comment

Choose a reason for hiding this comment

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

Thanks! LGTM, but let's make sure the changelog is clear about this improvement only applying to the v3 version of the API. (Which I assume, by now, most people should be using...?)

@regeda regeda changed the title refact: use protoreflect to convert check request refact: use protoreflect to convert check request v3 Jan 5, 2025
@regeda
Copy link
Contributor Author

regeda commented Jan 5, 2025

Thanks! LGTM, but let's make sure the changelog is clear about this improvement only applying to the v3 version of the API. (Which I assume, by now, most people should be using...?)

@srenatus I've updated the PR's title and the commit message. Should I update anything else?

@regeda regeda force-pushed the use-protoreflect-for-input branch from d3188d7 to 8c481e5 Compare January 5, 2025 10:23
Signed-off-by: Anthony Regeda <regedaster@gmail.com>
@regeda regeda force-pushed the use-protoreflect-for-input branch from 8c481e5 to 3d05fc4 Compare January 6, 2025 15:34
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.

2 participants