8000 [NEW] Expose resource pool statistics through crypto11.Context · Issue #119 · ThalesGroup/crypto11 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[NEW] Expose resource 8000 pool statistics through crypto11.Context #119

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

Open
eriklupander opened this issue Mar 13, 2025 · 0 comments
Open

[NEW] Expose resource pool statistics through crypto11.Context #119

eriklupander opened this issue Mar 13, 2025 · 0 comments

Comments

@eriklupander
Copy link
eriklupander commented Mar 13, 2025

Is your feature request related to a problem? Please describe.

I would like to produce metrics for the underlying resource pool. However, crypto11.Context does not export its pool field or its StatsJSON() or related methods.

Describe the solution you'd like

A naive approach is to diectly access the pool stats through StatsJSON(), i.e. adding:

func (c *Context) PoolStatsJSON() string {
    if c.pool != nil {
        return c.pool.StatsJSON()
    }
    return "" // or introduce error into the method signature.
}

Callees can then parse the returned JSON.

A more concise approach could be to construct a:

type PoolStats struct {
    Capacity int64
    Available int64
    // and so on for the metrics exposed by pool.ResourcePool through its accessor methods.
}

In the crypto11 package, a new ResourcePoolStats() method on crypto11.Context can be added:

func (c *Context) ResourcePoolStats() PoolStats {
     if c.pool == nil {
        return PoolStats{} // return empty
    }
    return PoolStats {
        Capacity: c.pool.Capacity(),
        Available: c.pool.Available(),
        // And so on...
    }
}

Note that I haven't explored any potential downsides to exposing pool statistics through crypto11.Context, for example if reading pool stats may cause (unnecessary) communication to happen with the underlying device.

Describe alternatives you've considered

No, not really. Since the stats are exposed on the pool.ResourcePool I believe it should be rather straightforward to expose them through crypto11.Context as well.

Additional context

I don't think exposing the full pool is necessary.

@eriklupander eriklupander changed the title [NEW] Expose resource pool statistics through crypto.Context [NEW] Expose resource pool statistics through crypto11.Context Mar 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant
0