{"id":17666418,"url":"https://github.com/spajus/libgfapi-ruby","last_synced_at":"2025-05-07T23:44:06.886Z","repository":{"id":14626454,"uuid":"17343894","full_name":"spajus/libgfapi-ruby","owner":"spajus","description":"Ruby bindings for libgfapi (GlusterFS API)","archived":false,"fork":false,"pushed_at":"2014-09-08T02:25:37.000Z","size":373,"stargazers_count":5,"open_issues_count":0,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-07T23:44:00.814Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/spajus.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-03-02T18:33:56.000Z","updated_at":"2019-11-19T05:16:33.000Z","dependencies_parsed_at":"2022-08-31T12:50:28.861Z","dependency_job_id":null,"html_url":"https://github.com/spajus/libgfapi-ruby","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spajus%2Flibgfapi-ruby","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spajus%2Flibgfapi-ruby/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spajus%2Flibgfapi-ruby/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spajus%2Flibgfapi-ruby/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/spajus","download_url":"https://codeload.github.com/spajus/libgfapi-ruby/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252973617,"owners_count":21834105,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-23T21:24:24.348Z","updated_at":"2025-05-07T23:44:06.871Z","avatar_url":"https://github.com/spajus.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# libgfapi-ruby\n\nRuby bindings for [libgfapi](https://github.com/gluster/glusterfs/blob/master/api/src/glfs.h)\n(GlusterFS API).\n\n[![Gem Version](https://badge.fury.io/rb/libgfapi-ruby.png)](http://badge.fury.io/rb/libgfapi-ruby)\n[![Code Climate](https://codeclimate.com/github/spajus/libgfapi-ruby.png?branch=master)](https://codeclimate.com/github/spajus/libgfapi-ruby)\n[![Dependency Status](https://gemnasium.com/spajus/libgfapi-ruby.png?branch=master)](https://gemnasium.com/spajus/libgfapi-ruby)\n\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n    gem 'libgfapi-ruby'\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install libgfapi-ruby\n\n## Usage\n\n```ruby\nrequire 'glusterfs'\n\n# Create virtual mount\nvolume = GlusterFS::Volume.new('my_volume')\nvolume.mount('1.2.3.4')\n\n# Create a new directory\ndir = GlusterFS::Directory.new(volume, '/some_dir')\ndir.create\n\n# Delete a directory\ndir = GlusterFS::Directory.new(volume, '/some_dir')\ndir.delete\n# or\nvolume.delete_dir('/some_dir')\n\n# Create a file from string or bytes\nfile = GlusterFS::File.new(volume, '/gfs/file/path')\nsize = file.write(data)\nputs \"Written #{size} bytes\"\n\n# Copy an existing file to gluster\nexisting_file = File.open('/path/to/file')\nfile = GlusterFS::File.new(volume, '/gfs/file/path')\nsize = file.write_file(existing_file)\nputs \"Written #{size} bytes\"\n\n# Read a file\nfile = GlusterFS::File.new(volume, '/gfs/file/path')\ncontents = file.read\n\n# Read a file into a Tempfile\nfile = GlusterFS::File.new(volume, '/gfs/file/path')\ntempfile = file.read_file\nputs \"Tempfile path: #{tempfile.path}\"\n\n# Delete a file\nfile = GlusterFS::File.new(volume, '/gfs/file/path')\nfile.delete\n# or\nvolume.delete_file('/gfs/file/path')\n\n# Unmount virtual mount\nvolume.unmount\n```\n\n## Troubleshooting\n- If volume mount fails, you may need to [set volume\n  option](http://gluster.org/community/documentation/index.php/Gluster_3.2:_Setting_Volume_Options)\n  to allow insecure RPC (`rpc-auth-allow-insecure on`).\n- If you get a SEGFAULT, it most likely means you're trying to do something without checking if\n  it's possible, i.e.:\n  1. Create a directory `/foo/bar` while `/foo` does not exist.\n  2. Write a file `/foo/bar/baz.txt` while `/foo/bar` directory does not exit.\n\n\n## Running Specs\n\nRun specs with `rake spec`. However, you need glusterfs-server running somewhere, and a test mount.\nIf you have it in the computer you want to run your tests at (Vagrant works fine), you can do this:\n\n1. Add `127.0.0.1 distfs` to `/etc/hosts`\n2. Run `gluster volume create dist-volume distfs:/dist1 force`\n3. Run `gluster volume start dist-volume`\n4. Run `rake spec`\n\nAnother option - use existing cluster, set following env variables before running tests:\n\n```bash\nexport GFS_VOLUME='volume-name'\nexport GFS_SERVER_HOST='1.2.3.4'\nexport GFS_SERVER_PORT=24007\nrake spec\n```\n\n## Performance\n\nThere is performance spec: `spec/glusterfs/stress/performance_spec.rb`. You can edit values at\n`spec/spec_helper.rb` or provide ENV variables to run it on your system. Here's how 1000 iterations\nof create/delete directories with various file sizes looks like:\n\n```\n# 5 Kb files\nNative FS Time:  1000 iterations:  0.1400 sec\nMounted FS Time: 1000 iterations: 44.0874 sec\nGFS API Time:    1000 iterations: 42.4865 sec\n\n# 70 Kb files\nNative FS Time:  1000 iterations:  0.6270 sec\nMounted FS Time: 1000 iterations: 79.2414 sec\nGFS API Time:    1000 iterations: 46.4481 sec\n\n# 5 Mb files\nNative FS Time:  1000 iterations:   6.1057 sec\nMounted FS Time: 1000 iterations:  94.8507 sec\nGFS API Time:    1000 iterations: 118.8812 sec\n```\n\nTests were run on CentOS with Intel(R) Xeon(R) CPU E5-2407 0 @ 2.20GHz, 128GB RAM, with following\nGlusterFS Volume configuration:\n\n```\nVolume Name: dist-volume\nType: Replicate\nVolume ID: \u003cskipped\u003e\nStatus: Started\nNumber of Bricks: 1 x 2 = 2\nTransport-type: tcp\nBricks:\nBrick1: server1:/var/lib/gfs/dist-volume\nBrick2: server2:/var/lib/gfs/dist-volume\nOptions Reconfigured:\nserver.allow-insecure: on\nfeatures.worm: disable\nnetwork.frame-timeout: 10\ndiagnostics.latency-measurement: on\nperformance.cache-size: 1024MB\ncluster.data-self-heal-algorithm: full\nnfs.disable: yes\nperformance.write-behind-window-size: 128MB\nperformance.cache-refresh-timeout: 10\n```\n\n## TODO\n\nMajor things missing:\n- Directory listing / traversal\n\n## Known issues\n\n`GlusterFS::Volume.mount / unmount` [leaks\nmemory](https://bugzilla.redhat.com/show_bug.cgi?id=1072854).\n\n## Contributing\n\n1. Fork it ( http://github.com/spajus/libgfapi-ruby/fork )\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create new Pull Request\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspajus%2Flibgfapi-ruby","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspajus%2Flibgfapi-ruby","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspajus%2Flibgfapi-ruby/lists"}