transaction 0.1.6.beta → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.MD +14 -1
- data/Gemfile.lock +1 -1
- data/README.md +14 -1
- data/lib/transaction/version.rb +1 -1
- data/lib/transaction.rb +15 -15
- data/transaction.gemspec +2 -2
- metadata +6 -12
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a526c5d4b3f377cb0058172dba2ec28cfc4c992034f2e67d3d27e58363f1d3bc
|
|
4
|
+
data.tar.gz: 6930f32bea0063cbc6dcae24a78793a11fb74034cc6f292a6ea53b8724566b1d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 45e2043fcb38a0379a6e3edebddaa162ebbb4d010936a22b32e70bc2c0cee889505f4cfb165a0bb03cca65c239af63bef7439154984afdee80a4c9cd5386bf6a
|
|
7
|
+
data.tar.gz: 833df05c837c87133e7a292cad3741f84a1cb8f01226715736e61ae73f404e6189daeb96ef7df729d9e601019fdd1a5e8d5ed41c4eb002426ed9f82a8d4c3c90
|
data/CHANGELOG.MD
CHANGED
|
@@ -4,7 +4,20 @@ All notable changes to this project will be documented in this file.
|
|
|
4
4
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
5
5
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
6
|
|
|
7
|
-
## [0.1.
|
|
7
|
+
## [0.1.7] - 2019-07-19
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
- Setter/getter for redis client.
|
|
11
|
+
- documentation for configuring redis.
|
|
12
|
+
|
|
13
|
+
### Changed
|
|
14
|
+
- allow fallback to local redis if no configuration provided.
|
|
15
|
+
|
|
16
|
+
### Removed
|
|
17
|
+
- configuration yeilder class.
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
## [0.1.6.beta] - 2019-07-19
|
|
8
21
|
|
|
9
22
|
### Added
|
|
10
23
|
- specs for update_attributes
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
|
@@ -30,6 +30,20 @@ Or install it yourself as:
|
|
|
30
30
|
|
|
31
31
|
## Usage
|
|
32
32
|
|
|
33
|
+
### Initializing Transaction gem -
|
|
34
|
+
|
|
35
|
+
Connecting to redis via initializer (Rails app)
|
|
36
|
+
```ruby
|
|
37
|
+
Transaction.configure do |config|
|
|
38
|
+
config.redis = Redis.new(url: 'redis://redis_url:6379') # defaults to localhost
|
|
39
|
+
end
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Connecting to redis directly
|
|
43
|
+
```ruby
|
|
44
|
+
Transaction.redis = Redis.new(url: 'redis://redis_url:6379')
|
|
45
|
+
```
|
|
46
|
+
|
|
33
47
|
### Initializing a transaction
|
|
34
48
|
A transaction can be newly initialized or be found with the given transaction_id. If no transaction is found then a new transaction in created.
|
|
35
49
|
```ruby
|
|
@@ -103,7 +117,6 @@ Let's say we have 2 transactions `t1` and `t2` both initialized with same transa
|
|
|
103
117
|
transaction = Transaction::Client.new
|
|
104
118
|
transaction.start!
|
|
105
119
|
task2(transaction.transaction_id)
|
|
106
|
-
sleep(5) # just letting task 2 finish.
|
|
107
120
|
|
|
108
121
|
puts transaction.status # 'processing'
|
|
109
122
|
transaction.refresh!
|
data/lib/transaction/version.rb
CHANGED
data/lib/transaction.rb
CHANGED
|
@@ -6,10 +6,6 @@ require 'redis'
|
|
|
6
6
|
require 'json'
|
|
7
7
|
|
|
8
8
|
module Transaction
|
|
9
|
-
class << self
|
|
10
|
-
attr_accessor :configuration
|
|
11
|
-
end
|
|
12
|
-
|
|
13
9
|
STATUSES = %i[queued processing success error].freeze
|
|
14
10
|
|
|
15
11
|
DEFAULT_ATTRIBUTES = {
|
|
@@ -17,16 +13,20 @@ module Transaction
|
|
|
17
13
|
}.freeze
|
|
18
14
|
|
|
19
15
|
def self.configure
|
|
20
|
-
self
|
|
21
|
-
yield(configuration)
|
|
16
|
+
yield self
|
|
22
17
|
end
|
|
23
18
|
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
def self.redis=(hash = {})
|
|
20
|
+
@redis = if hash.instance_of?(Redis)
|
|
21
|
+
hash
|
|
22
|
+
else
|
|
23
|
+
Redis.new(hash)
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
def self.redis
|
|
28
|
+
# use default redis if not set
|
|
29
|
+
@redis ||= Redis.new
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
class Client
|
|
@@ -35,7 +35,7 @@ module Transaction
|
|
|
35
35
|
def initialize(transaction_id: nil, options: {})
|
|
36
36
|
@transaction_id = transaction_id ||
|
|
37
37
|
"transact-#{SecureRandom.urlsafe_base64(16)}"
|
|
38
|
-
@
|
|
38
|
+
@redis_client = Transaction.redis
|
|
39
39
|
|
|
40
40
|
options = DEFAULT_ATTRIBUTES.merge(options)
|
|
41
41
|
|
|
@@ -116,15 +116,15 @@ module Transaction
|
|
|
116
116
|
|
|
117
117
|
# redis methods
|
|
118
118
|
def redis_get
|
|
119
|
-
@
|
|
119
|
+
@redis_client.get(@transaction_id)
|
|
120
120
|
end
|
|
121
121
|
|
|
122
122
|
def redis_set(key, value)
|
|
123
|
-
@
|
|
123
|
+
@redis_client.set(key, value)
|
|
124
124
|
end
|
|
125
125
|
|
|
126
126
|
def redis_delete
|
|
127
|
-
@
|
|
127
|
+
@redis_client.del(@transaction_id)
|
|
128
128
|
end
|
|
129
129
|
end
|
|
130
130
|
|
data/transaction.gemspec
CHANGED
|
@@ -10,8 +10,8 @@ Gem::Specification.new do |spec|
|
|
|
10
10
|
spec.authors = ['Anurag Tiwari']
|
|
11
11
|
spec.email = ['tiwari.anurag126@gmail.com']
|
|
12
12
|
|
|
13
|
-
spec.summary = '
|
|
14
|
-
spec.description = '
|
|
13
|
+
spec.summary = 'Record status along with other relevant information of transactions/tasks.'
|
|
14
|
+
spec.description = 'Record status along with other relevant information of transactions/tasks.'
|
|
15
15
|
spec.homepage = 'https://github.com/t2013anurag/transaction'
|
|
16
16
|
spec.license = 'MIT'
|
|
17
17
|
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: transaction
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.7
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Anurag Tiwari
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2019-07-
|
|
11
|
+
date: 2019-07-21 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: redis
|
|
@@ -80,12 +80,7 @@ dependencies:
|
|
|
80
80
|
- - ">="
|
|
81
81
|
- !ruby/object:Gem::Version
|
|
82
82
|
version: '0'
|
|
83
|
-
description:
|
|
84
|
-
transactions is difficult especially when information about the transaction is of
|
|
85
|
-
importance. This library helps you manage information relevant to the transaction.
|
|
86
|
-
Current status and additional info about the task is stored is stored in redis datastore.
|
|
87
|
-
This information can be retrieved at any point of time until the transaction is
|
|
88
|
-
expired.
|
|
83
|
+
description: Record status along with other relevant information of transactions/tasks.
|
|
89
84
|
email:
|
|
90
85
|
- tiwari.anurag126@gmail.com
|
|
91
86
|
executables: []
|
|
@@ -125,14 +120,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
125
120
|
version: 2.4.0
|
|
126
121
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
127
122
|
requirements:
|
|
128
|
-
- - "
|
|
123
|
+
- - ">="
|
|
129
124
|
- !ruby/object:Gem::Version
|
|
130
|
-
version:
|
|
125
|
+
version: '0'
|
|
131
126
|
requirements: []
|
|
132
127
|
rubyforge_project:
|
|
133
128
|
rubygems_version: 2.7.6
|
|
134
129
|
signing_key:
|
|
135
130
|
specification_version: 4
|
|
136
|
-
summary:
|
|
137
|
-
transaction.
|
|
131
|
+
summary: Record status along with other relevant information of transactions/tasks.
|
|
138
132
|
test_files: []
|