floe 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3a8984568027905b79c95ab066b45f0e87872bbb290022a018f3574d47e3054e
4
- data.tar.gz: 73390d044e75811f2b1c91acfa1aea1814b38f1d3a60ad4b9bd0eed88d131af0
3
+ metadata.gz: b6602a2b11185c6d720b8be59bc69f0e5b115af19e23f64a0e8718fdc8828321
4
+ data.tar.gz: cf88494cf2e4e3ae9227a5f0e7a19cf91c6e7d20f691fc36643b870e10255afd
5
5
  SHA512:
6
- metadata.gz: b5d6cec81ef1adc60cc5912cc34275c032f250d84361982ac556284ada3c807f3189eef5357c193ae5b76db795f328b761fd53fd5dbfcd3468e5fc439d54c9fe
7
- data.tar.gz: d4a9ce5beea167b41ec66b1b049c6466a41c91b64076792e87b34e92787e19120965580c638a755c5a1e406398f4b1842851105dad2d388c21b7db76944c7df7
6
+ metadata.gz: b1ffab71c8fc58a0190aa6e2a7db223f7b9968bb78d8cb08fadfcbd3b8edcac2f155aa92125f92e259f3c1423fe98ac61508cec71ee6aaca52b2135e819e9b26
7
+ data.tar.gz: 500f7734ecd0e6731d0324db59eecb50f1f0b99efbb33e6a0acc0e9dfbdde6f6c18a3a2b074c271f16b8dd64971aec4ae42e2810819eb9765c39e8c2b6ce0c1b
data/CHANGELOG.md CHANGED
@@ -4,6 +4,13 @@ This project adheres to [Semantic Versioning](http://semver.org/).
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [0.2.1] - 2023-07-12
8
+ ### Fixed
9
+ - Fix State EnteredTime and FinishedTime (#59)
10
+
11
+ ### Added
12
+ - Add workflow output (#57)
13
+
7
14
  ## [0.2.0] - 2023-07-05
8
15
  ### Added
9
16
  - Add ability to pass options to `Floe::Workflow::Runner` (#48)
@@ -23,4 +30,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
23
30
  ### Added
24
31
  - Initial release
25
32
 
26
- [Unreleased]: https://github.com/ManageIQ/floe/compare/v0.1.0...HEAD
33
+ [Unreleased]: https://github.com/ManageIQ/floe/compare/v0.2.1...HEAD
34
+ [0.2.1]: https://github.com/ManageIQ/floe/compare/v0.2.0...v0.2.1
35
+ [0.2.0]: https://github.com/ManageIQ/floe/compare/v0.1.1...v0.2.0
36
+ [0.1.1]: https://github.com/ManageIQ/floe/compare/v0.1.0...v0.1.1
37
+ [0.1.0]: https://github.com/ManageIQ/floe/tree/v0.1.0
data/exe/floe CHANGED
@@ -36,4 +36,4 @@ Floe::Workflow::Runner.docker_runner = runner_klass.new(runner_options)
36
36
 
37
37
  workflow.run!
38
38
 
39
- puts workflow.context.state["Output"].inspect
39
+ puts workflow.output.inspect
data/lib/floe/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Floe
4
- VERSION = "0.2.0"
4
+ VERSION = "0.2.1"
5
5
  end
@@ -25,6 +25,10 @@ module Floe
25
25
  @context["State"]
26
26
  end
27
27
 
28
+ def state=(val)
29
+ @context["State"] = val
30
+ end
31
+
28
32
  def states
29
33
  @context["States"]
30
34
  end
data/lib/floe/workflow.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "securerandom"
3
4
  require "json"
4
5
 
5
6
  module Floe
@@ -11,7 +12,7 @@ module Floe
11
12
  end
12
13
  end
13
14
 
14
- attr_reader :context, :credentials, :payload, :states, :states_by_name, :current_state, :status
15
+ attr_reader :context, :credentials, :output, :payload, :states, :states_by_name, :current_state, :status
15
16
 
16
17
  def initialize(payload, context = nil, credentials = {})
17
18
  payload = JSON.parse(payload) if payload.kind_of?(String)
@@ -27,7 +28,7 @@ module Floe
27
28
  @states_by_name = @states.each_with_object({}) { |state, result| result[state.name] = state }
28
29
  start_at = @payload["StartAt"]
29
30
 
30
- current_state_name = @context["State"]["Name"] || start_at
31
+ current_state_name = context.state["Name"] || start_at
31
32
  @current_state = @states_by_name[current_state_name]
32
33
 
33
34
  @status = current_state_name == start_at ? "pending" : current_state.status
@@ -37,26 +38,29 @@ module Floe
37
38
 
38
39
  def step
39
40
  @status = "running" if @status == "pending"
40
- @context["Execution"]["StartTime"] ||= Time.now.utc
41
+ context.execution["StartTime"] ||= Time.now.utc
41
42
 
42
- input = @context["State"]["Output"] || @context["Execution"]["Input"].dup
43
+ input = context.state["Output"] || context.execution["Input"].dup
44
+
45
+ context.state = {
46
+ "Guid" => SecureRandom.uuid,
47
+ "EnteredTime" => Time.now.utc,
48
+ "Input" => input,
49
+ "Name" => current_state.name
50
+ }
43
51
 
44
52
  tick = Process.clock_gettime(Process::CLOCK_MONOTONIC)
45
53
  next_state, output = current_state.run!(input)
46
54
  tock = Process.clock_gettime(Process::CLOCK_MONOTONIC)
47
55
 
48
- @context["State"] = {
49
- "EnteredTime" => tick,
50
- "FinishedTime" => tock,
51
- "Duration" => tock - tick,
52
- "Output" => output,
53
- "Name" => next_state&.name,
54
- "Input" => output
55
- }
56
+ context.state["FinishedTime"] = Time.now.utc
57
+ context.state["Duration"] = (tock - tick) / 1_000_000.0
58
+ context.state["Output"] = output
56
59
 
57
- @context["States"] << @context["State"]
60
+ context.states << context.state
58
61
 
59
62
  @status = current_state.status
63
+ @output = output if end?
60
64
 
61
65
  next_state_name = next_state&.name
62
66
  @current_state = next_state_name && @states_by_name[next_state_name]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: floe
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - ManageIQ Developers
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-07-06 00:00:00.000000000 Z
11
+ date: 2023-07-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: awesome_spawn