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

aya: Make FEATURES public #531

Merged
merged 1 commit into from
Jul 2, 2023
Merged

Conversation

dave-tucker
Copy link
Member

This commit adds a new probe for bpf_attach_cookie, which would be used to implement USDT probes. Since USDT probes aren't currently supported, this triggers a dead_code warning in clippy.

There are cases where exposing FEATURES - our lazy static - is actually helpful to users of the library. For example, they may wish to choose to load a different version of their bytecode based on current features. Or, in the case of an orchestrator like bpfd, we might want to allow users to describe which features their program needs and return nice error message is one or more nodes in their cluster doesn't support the necessary feature set.

@netlify
Copy link

netlify bot commented Feb 23, 2023

Deploy Preview for aya-rs-docs ready!

Name Link
🔨 Latest commit 47f764c
🔍 Latest deploy log https://app.netlify.com/sites/aya-rs-docs/deploys/64a1926a082c1d0008592083
😎 Deploy Preview https://deploy-preview-531--aya-rs-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@dave-tucker dave-tucker added aya This is about aya (userspace) api/needs-review Makes an API change that needs review feature A PR that implements a new feature or enhancement labels Feb 23, 2023
@alessandrod
Copy link
Collaborator

We can't expose the static because it leaks lazy_static API (you need to call .get() or deref), and we can't expose the Features type as it is as it would be the ultimate API breaking type: every new feature breaks API.

What we can do is to add a features() -> &'static Features util function somewhere, and then add pub method accessors for all the still private fields in Features. That would allow us to add features without breaking API.

Copy link
Collaborator

@alessandrod alessandrod left a comment

Choose a reason for hiding this comment

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

See other comment

@dave-tucker dave-tucker force-pushed the probe-cookie branch 2 times, most recently from 14ebd51 to c6d4533 Compare July 2, 2023 14:34
Copy link
Collaborator

@alessandrod alessandrod left a comment

Choose a reason for hiding this comment

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

Thanks! See doc nits, then it's ready to go

aya-obj/src/btf/btf.rs Show resolved Hide resolved
aya-obj/src/obj.rs Show resolved Hide resolved
This commit adds a new probe for bpf_attach_cookie, which would be used
to implement USDT probes. Since USDT probes aren't currently supported,
we this triggers a dead_code warning in clippy.

There are cases where exposing FEATURES - our lazy static - is actually
helpful to users of the library. For example, they may wish to choose to
load a different version of their bytecode based on current features.
Or, in the case of an orchestrator like bpfd, we might want to allow
users to describe which features their program needs and return nice
error message is one or more nodes in their cluster doesn't support the
necessary feature set.

To do this without breaking the API, we make all the internal members of
the `Features` and `BtfFeatures` structs private, and add accessors for
them. We then add a `features()` API to avoid leaking the
lazy_static.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
@dave-tucker dave-tucker merged commit bc0d021 into aya-rs:main Jul 2, 2023
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api/needs-review Makes an API change that needs review aya This is about aya (userspace) feature A PR that implements a new feature or enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants