Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add thread safe method of querying BigCommerce resources. #123

Merged
merged 1 commit into from
Jun 24, 2016
Merged

Add thread safe method of querying BigCommerce resources. #123

merged 1 commit into from
Jun 24, 2016

Conversation

pedelman
Copy link
Contributor

@pedelman pedelman commented Jun 21, 2016

Example usage

# Thread safe
conn = Bigcommerce::Connection.build(
  Bigcommerce::Config.new(
    store_hash: ENV['BC_STORE_HASH'], 
    client_id: ENV['BC_CLIENT_ID'], 
    access_token: ENV['BC_ACCESS_TOKEN']
  )
)

Bigcommerce::System.time(connenction: conn)
=> #<Bigcommerce::System time=1466546702>

Bigcommerce::System.raw_request(:get, '/time', connection: conn)
=> #<Faraday::Response:0x007fd4a4063170 ... >>
# Not thread safe
Bigcommerce.configure do |config|
  config.store_hash = ENV['BC_STORE_HASH']
  config.client_id = ENV['BC_CLIENT_ID']
  config.access_token = ENV['BC_ACCESS_TOKEN']
end

Bigcommerce::System.time
=> #<Bigcommerce::System time=1466546702>

Bigcommerce::System.raw_request(:get, '/time')
=> #<Faraday::Response:0x007fd4a4063170 ... >>

Fixes #98

@pedelman
Copy link
Contributor Author

@@ -0,0 +1,26 @@
module Bigcommerce
class Connection
attr_reader :connection
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this for?

@gregory
Copy link
Contributor

gregory commented Jun 23, 2016

had a quick high level overview but not tested.
Overall looks good!
One thing i'm not really a fan of is tempering with parameters
I do believe that passing connection objects is the way to go to solve thread safety but also have the ability to query multiple stores.

@gregory
Copy link
Contributor

gregory commented Jun 23, 2016

Also, don't you feel like it's kind of a "hack" to allow to pass parameters, just to be able to sneak in the connection object? :)

What i'm saying is that you allow me to do this: Bigcommerce::System.time(foo: 'bar') but this is just so you can pass in a connection: Bigcommerce::System.time(connenction: conn)

@mattolson
Copy link
Contributor

👍

@mattolson mattolson merged commit cdc661c into bigcommerce:master Jun 24, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants