Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Build Fog gem with just required providers and limit dependencies

Tags:

ruby

fog

I'm using the excellent Fog gem to access just the Rackspace Cloud Files service. My challenge is that I'm trying to keep the service that is accessing Cloud Files lightweight, and it seems that Fog through its flexibility has a lot of dependencies and code I'll never need.

Has anybody tried to build a slimmed down copy of Fog, just to include a subset of providers, and therefore limit the dependencies? For example, for the Rackspace Cloud Files API exclusively, I'd expect to be able to handle everything without net-ssh, net-scp, nokogiri gems, and all the unused code for Amazon, Rackspace and 20 other providers that are not being used. I'm hoping to avoid upgrading the gem every time one of those unused providers notices a bug, while keeping my memory footprint down.

I'd appreciate any experience anybody may have in doing this, or advice from anybody familiar with building Fog in what I can and can't rip out.

If I'm just using the wrong gem, then that's equally fine. I'll move to something more focused.

like image 218
Phil Avatar asked Jan 03 '14 22:01

Phil


People also ask

Should I be using a metagem for my fog provider?

Currently all fog providers are getting separated into metagems to lower the load time and dependency count. If there's a metagem available for your cloud provider, e.g. fog-aws , you should be using it instead of requiring the full fog collection to avoid unnecessary dependencies.

When should 'fog' be required explicitly?

'fog' should be required explicitly only if the provider you use doesn't yet have a metagem available. The easiest way to learn fog is to install the gem and use the interactive console. Here is an example of wading through server creation for Amazon Elastic Compute Cloud: Fog requires Ruby 2.0.0 or later.

What Ruby versions are supported by fog-v2?

Fog requires Ruby 2.0.0 or later. Ruby 1.8 and 1.9 support was dropped in fog-v2.0.0 as a backwards incompatible change. Please use the later fog 1.x versions if you require 1.8.7 or 1.9.x support. A high level interface to each cloud is provided through collections, such as images and servers .

Is fog library compatible with semantic versioning?

geemus says: "That should give you everything you need to get started, but let me know if there is anything I can do to help!" Fog library aims to adhere to Semantic Versioning 2.0.0, although it does not address challenges of multi-provider libraries. Semantic versioning is only guaranteed for the common API, not any provider-specific extensions.


2 Answers

I'm the maintainer of fog so I'll chime in to help fill in some of the explanation/gaps. The short answer is, yeah it's a lot of stuff, but mostly it shouldn't impact you negatively.

First off, fog grew pretty organically over time, so it did get bigger than intended. One of the ways that we contend with this is that we rather aggressively avoid requiring/loading files until really needed. So although you have to download lots of provider files you won't use to install fog, they shouldn't actually end up in memory. That was the simplest thing we could do in order to keep things "just working" while also reducing the memory usage (and load time).

The release schedule doesn't tend to be too crazy (on average about once a month) and tends to include a mix of stuff across most of the providers. So I'd expect you won't have too much churn here (outside of emergency/security type fixes which might warrant shortening the normal cycle).

So, that hopefully provides some insight in to the state of the art. We have also discussed starting to split things out more in the longer term. I think if/when that happens we would end up with something like fog-rackspace for all the rackspace related things. And then they could share things through fog-core or similar. We have a rough outline, but it is a pretty big undertaking without a huge upside, so it isn't something we have really actively begun on.

Hope that helps, certainly happy to discuss further if you have further questions or concerns.

like image 187
geemus Avatar answered Oct 19 '22 17:10

geemus


I work for Rackspace on, among other things, our Ruby SDKs. You're using the right gem. Fog is our official Ruby API.

This is possibly something that could be done by introducing another gemspec into the project that builds from only fog core and the Rackspace-specific files. Though this would be unconventional and make @geemus' (the gem maintainer) gem release process more complicated––especially should other providers start to do the same. Longer term, this would serve to divert the fog community away from acting as a unified API.

like image 45
elight Avatar answered Oct 19 '22 17:10

elight