Giter Club home page Giter Club logo

activemodel-datastore's People

Contributors

bmclean avatar rjmooney avatar rud avatar shao1555 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

activemodel-datastore's Issues

Exclude index on individual properties

We need the ability to exclude indexes on individual entity properties. For example, we can't currently create a string property that exceeds 1500 bytes.

The gcloud client supports this:

entity.exclude_from_indexes! :content, true # This allows a string up to 1,048,487 bytes.

Review the methods retried on exception

We need to review if we should still be retrying the save, update and destroy methods.

Also review if it is still necessary on any Lookup or RunQuery. The GAX client does provide a retry mechanism as defined here.

For a datastore Lookup, since it has a retry_codes_name defined of "idempotent", if an UNAVAILABLE error was raised, it would retry using the default params.
For a datastore Commit, since it has a retry_codes_name defined of "non_idempotent", any error raised would not be retried.

It provides an exponential back-off for the desired error codes with a max overall timeout (so it won't retry forever) but also allows a force retry after a specific time.

"initial_rpc_timeout_millis": 5000
(the initial timeout parameter to the request)
Times out if a response is not initially received within 5 sec.

"initial_retry_delay_millis": 500
(the initial delay time, in milliseconds, between the completion of the first failed request and the initiation of the first retrying request)
Waits 0.5s and automatically retries the request.

"rpc_timeout_multiplier": 1.0
(the multiplier by which to increase the timeout parameter between failed requests)
Would wait 5 seconds after the retry before timing out.

"retry_delay_multiplier": 2.0
(the multiplier by which to increase the delay time between the completion of failed requests, and the initiation of the subsequent retrying request)
The request will keep being retried with an exponential back-off (0.50, 1, 2) waiting 5 seconds for each request until it succeeds or finally:

"total_timeout_millis": 17000
(the total time, in milliseconds, starting from when the initial request is sent, after which an error will be returned, regardless of the retrying attempts made meanwhile)

validating uniqueness

I was wondering if there is a built in way to do this, and/or what the best/proper way would be. Would love it if there was syntax like:

validates :email, uniqueness: true

Support parent key name as well as parent key id

We currently support the parent_key_id attribute as an integer id. We should add support for also using a parent key string name. Something like id_or_name.

Example:

def build_model(entity)
  model_entity = new
  model_entity.id = entity.key.id unless entity.key.id.nil?
  model_entity.id = entity.key.name unless entity.key.name.nil?
  if entity.key.parent.present?
    model_entity.parent_key_id = entity.key.parent.id if entity.key.parent.id.present?
    model_entity.parent_key_id = entity.key.parent.name if entity.key.parent.name.present?
  end
  model_entity
end

GAE Production authentication is overridden with emulator settings

GAE Production authentication appears to be overridden with hardcoded emulator settings. The initialization code in lib/active_model/datastore/connection.rb overrides the GCLOUD_PROJECT environment variable with the test datastore project and sets DATASTORE_EMULATOR_HOST regardless of the existing environment. The latter forces emulator usage.

module CloudDatastore
  if defined?(Rails) == 'constant'
    if Rails.env.development?
      ENV['DATASTORE_EMULATOR_HOST'] = 'localhost:8180'
      ENV['GCLOUD_PROJECT'] = 'local-datastore'
    elsif Rails.env.test?
      ENV['DATASTORE_EMULATOR_HOST'] = 'localhost:8181'
      ENV['GCLOUD_PROJECT'] = 'test-datastore'
    elsif ENV['SERVICE_ACCOUNT_PRIVATE_KEY'].present? &&
          ENV['SERVICE_ACCOUNT_CLIENT_EMAIL'].present?
      ENV['GCLOUD_KEYFILE_JSON'] = '{"private_key": "' + ENV['SERVICE_ACCOUNT_PRIVATE_KEY'] + '",
      "client_email": "' + ENV['SERVICE_ACCOUNT_CLIENT_EMAIL'] + '"}'
    end
  else
    ENV['DATASTORE_EMULATOR_HOST'] = 'localhost:8181'
    ENV['GCLOUD_PROJECT'] = 'test-datastore'
  end

  def self.dataset
    @dataset ||= Google::Cloud.datastore(ENV['GCLOUD_PROJECT'])
  end
...

Maybe I'm missing something but it seems the model should not override the environment and simply allow Google::Cloud.datastore to initialize using the existing environment per the Google Cloud Client Library convention.

Dirty tracking clarification

I noticed that the dirty tracking "is to be documented" in the readme. I played around with it and noticed to my surprise that changes are not wiped after a successful save/save! is it intentional that one would have to manually call reload! on the objects to reset the change tracking after a save to data store?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.