https://github.com/puppetlabs/jruby-utils
Tools for working with JRuby from Clojure
https://github.com/puppetlabs/jruby-utils
Last synced: about 2 months ago
JSON representation
Tools for working with JRuby from Clojure
- Host: GitHub
- URL: https://github.com/puppetlabs/jruby-utils
- Owner: puppetlabs
- License: other
- Created: 2016-03-28T22:45:23.000Z (over 9 years ago)
- Default Branch: main
- Last Pushed: 2025-02-06T23:07:15.000Z (5 months ago)
- Last Synced: 2025-05-07T20:09:03.739Z (about 2 months ago)
- Language: Clojure
- Size: 4.01 MB
- Stars: 5
- Watchers: 86
- Forks: 23
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Codeowners: CODEOWNERS
Awesome Lists containing this project
README
# JRuby Utils
A library for creating and interacting with a pool of JRuby instances in
Clojure.[](https://travis-ci.org/puppetlabs/jruby-utils)
## Usage
This is a brief overview of the functionality of this library; TODO add more docs.
This library provides three public namespaces:
`puppetlabs.services.jruby-pool-manager.jruby-schemas`,
`puppetlabs.services.jruby-pool-manager.jruby-pool-manager-service`, and
`puppetlabs.services.jruby-pool-manager.jruby-core`.The entry-point into most of the functionality this library provides is the
`jruby-pool-manager-service` Trapperkeeper service's `create-pool`, which
creates and returns a pool context and asynchronously starts filling the pool.`create-pool` takes a config matching the `JRubyConfig` schema; this config
can be created and provided defaults by the `jruby-core/initialize-config`
function. The non-optional config settings that you must provide are
`ruby-load-path` and `gem-home`.You can provide custom initialization and callback logic by providing
lifecycle functions for initializing the scripting container, initializing the
pool instance, cleaning up a pool instance, and cleaning up the pool for
shutdown.After the pool has been created, use the `borrow` and `return` functions to
work with instances. There is a `with-jruby-instance` macro to make this
easier. There is also a `with-lock` macro that holds a lock on the pool (so
that no borrows can take place) while you execute some logic.In most TK apps where you want to work with JRuby instances, you will want to
call `create-pool` in the `init` lifecycle of your service, and then call
`jruby-core/flush-pool-for-shutdown!` in the `stop` lifecycle function.## Running tests
To run the clojure unit tests, use:
~~~sh
lein test
~~~## License
See [LICENSE](LICENSE).
## Support
We use the [Trapperkeeper project on
JIRA](https://tickets.puppetlabs.com/browse/TK) for tickets on this project,
although Github issues are welcome too.