A collection of Ruby libraries for working with SQL on top of ActiveRecord's connection
A collection of Ruby libraries for working with SQL on top of ActiveRecord's connection
GitHub::DS is a collection of Ruby libraries for working with SQL on top of ActiveRecord's connection.
GitHub::KV is a key/value data store backed by MySQL.GitHub::SQL is for building and executing a SQL query. This class uses ActiveRecord's connection class, but provides a better API for bind values and raw data access.GitHub::Result makes it easier to bake in resiliency through the use of a Result object instead of raising exceptions.Current Status: Used in production extensively at GitHub. Because of this, all changes will be thoroughly vetted, which could slow down the process of contributing. We will do our best to actively communicate status of pull requests with any contributors. If you have any substantial changes that you would like to make, it would be great to first open an issue to discuss them with us.
Add this line to your application's Gemfile:
gem 'github-ds'And then execute:
$ bundleOr install it yourself as:
$ gem install github-dsBelow is a taste of what you can do with these libraries. If you want to see more, check out the examples directory.
First, you'll need to create the key_values table using the included Rails migration generator.
rails generate github:ds:active_record
rails db:migrateIf you need to change the name of the table used for storing the key-values, you can configure your table name as such, before running the migration:
GitHub::KV.configure do |config|
config.table_name = "new_key_values_table"
endOnce you have created and executed the migration, KV can do neat things like this:
…Note that due to MySQL's default collation, KV keys are case-insensitive.
…KV supports expiring keys and obeys expiration when performing operations, but does not actually purge expired rows. At GitHub, we use pt-archiver to nibble expired rows. We configure it to do a replica lag check and use the following options:
"index_key_values_on_expires_at"1000"expires_at <= NOW()"After checking out the repo, run script/bootstrap to install dependencies. Then, run script/test to run the tests. You can also run script/console for an interactive prompt that will allow you to experiment.
Note: You will need a MySQL database with no password set for the root user for the tests. Running docker-compose up will boot just that. This functionality is not currently used by GitHub and was from a contributor, so please let us know if it does not work or gets out of date (pull request is best, but an issue will do).
To install this gem onto your local machine, run script/install. To release a new version, update the version number in version.rb, commit, and then run script/release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.
Bug reports and pull requests are welcome on GitHub at https://github.com/github/github-ds. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct. We recommend reading the contributing guide as well.
Nothing currently on our radar other than continued maintenance. Have a big idea? Let us know.
| pic | @mention |
|---|---|
| @haileysome | |
| @jnunemaker | |
| @miguelff | |
| @zerowidth |
The gem is available as open source under the terms of the MIT License.
No open issues yet, or sync has not completed.