functions_framework 1.0.0 → 1.2.0

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: feaa072a9d05a5a0308e4721d338aea1d5bdcb65d257f74210073518d3f21735
4
- data.tar.gz: ef5d554a4ebf4dcb5e5d00b88f17ac36bd151d3b061038a35a26ed520dcd02b7
3
+ metadata.gz: 7f26316991786d4688dc35bab52d91d7df30c11fa573b5e5e9678b095d3e2047
4
+ data.tar.gz: 9b900e5156d42e4acdae4a8312bc25b866202f738f84ed9e264815fb2635ef42
5
5
  SHA512:
6
- metadata.gz: 699655e4efcd96b4fa46ccf2017f38d76848b2827115909b599bd722d2eb0d447da1fb3bc0323f825bf0b69024f1a947eaf969e95b205d90e6393babe2b8c15e
7
- data.tar.gz: 297c2eda593a1b995c233b7ff89d92e11c7921322bceeb14eac71eb351bf04d0956e6c0de18e91137884ace3fc6f0a4422c2e3b79d7598fdc0ab567f93bfe638
6
+ metadata.gz: 75180c4a931148fff3490084a4a43bacbcc65089812a18b397f9781f4e5e0899db5acde266f27bbf25f325c23d18c987abb4a1671125cb8db049b77da4b05a59
7
+ data.tar.gz: f7f95a82b95ab9e7b6f4f4dd16f455dac9f3ea71549401b6bc6b781b6b011741f4e9b59ef97fb444c2b0fbec718eb0f8f92895f1a2a7adbd8f404e590c22d124
data/CHANGELOG.md CHANGED
@@ -1,6 +1,22 @@
1
1
  # Changelog
2
2
 
3
- ### v1.0.0 / 2021-07-07
3
+ ### 1.2.0 (2022-08-25)
4
+
5
+ * Update minimum Ruby version to 2.6
6
+ * Increase default max thread pool size to 16
7
+
8
+ ### 1.1.0 (2022-01-18)
9
+
10
+ * Increase default max thread pool size to 8.
11
+ * Return 204 when a GET request is sent to an event function, to support health checks.
12
+ * Flush stdout and stderr streams at the end of each request.
13
+ * Format the error backtrace.
14
+
15
+ ### 1.0.1 (2021-09-10)
16
+
17
+ * FIXED: Update legacy event conversion to set the correct types for firebase database events
18
+
19
+ ### 1.0.0 (2021-07-07)
4
20
 
5
21
  * Bumped the version to 1.0.
6
22
  * Removed the "preview" notices for Google Cloud Functions since the Ruby runtime is now GA.
data/README.md CHANGED
@@ -42,14 +42,14 @@ requiring an HTTP server or complicated request handling logic.
42
42
 
43
43
  ## Supported Ruby versions
44
44
 
45
- This library is supported on Ruby 2.5+.
45
+ This library is supported on Ruby 2.6+.
46
46
 
47
47
  Google provides official support for Ruby versions that are actively supported
48
48
  by Ruby Core—that is, Ruby versions that are either in normal maintenance or
49
- in security maintenance, and not end of life. Currently, this means Ruby 2.5
50
- and later. Older versions of Ruby _may_ still work, but are unsupported and not
51
- recommended. See https://www.ruby-lang.org/en/downloads/branches/ for details
52
- about the Ruby support schedule.
49
+ in security maintenance, and not end of life. Older versions of Ruby _may_
50
+ still work, but are unsupported and not recommended. See
51
+ https://www.ruby-lang.org/en/downloads/branches/ for details about the Ruby
52
+ support schedule.
53
53
 
54
54
  ## Quickstart
55
55
 
data/RELEASING.md ADDED
@@ -0,0 +1,78 @@
1
+ # Releasing
2
+
3
+ Releases are performed using tooling developed by Google's GitHub Automation
4
+ team, and are partially automated, but can be controlled by maintainers.
5
+
6
+ ## The automated release pipeline
7
+
8
+ Whenever a commit is pushed to the main branch with a
9
+ [Conventional Commit](https://www.conventionalcommits.org/en/v1.0.0/) message,
10
+ the automated release pipeline will trigger.
11
+
12
+ ### Release pull requests
13
+
14
+ The [release-please](https://github.com/googleapis/release-please) bot watches
15
+ for commits that indicate a semantic change, normally either `feat:` or `fix:`,
16
+ or any commit that includes a breaking change. When new commits are pushed,
17
+ release-please will propose a new release whose version is based on the semver
18
+ implication of the change: a patch release for a `fix:`, a minor release for a
19
+ `feat:`, or a major release for a breaking change. This will appear in the form
20
+ of a pull request, which will include the proposed new version, and a changelog
21
+ entry.
22
+
23
+ A maintainer can either:
24
+
25
+ * Close the pull request to defer the release until more changes have been
26
+ committed.
27
+ * Accept the release by merging the pull request, possibly after modifying the
28
+ changelog.
29
+
30
+ Do NOT modify the version in the pull request. If you want to release a
31
+ different version, see the next section on proposing releases manually.
32
+
33
+ When merging a release pull request, make sure the `autorelease: pending` label
34
+ remains applied. This is important for correct operation of the rest of the
35
+ release pipeline.
36
+
37
+ ### Release scripts
38
+
39
+ After a release pull request is merged, another bot will trigger the rest of
40
+ the release pipeline. This bot runs every 15 minutes, so this process may be
41
+ delayed a few minutes. Once it runs, it will do the following automatically:
42
+
43
+ * Tag the release and create a GitHub release. This takes place in a kokoro
44
+ (internal Google) job. Once finished, it will switch the tag from
45
+ `autorelease: pending` to `autorelease: tagged`. If it seems to be
46
+ malfunctioning, you can find logs on the internal fusion dashboard under the
47
+ job `cloud-devrel/client-libraries/autorelease/tag`.
48
+ * Build and push the gem to Rubygems, and build and push the documentation to
49
+ googleapis.dev. This takes place in a second kokoro job. Once finished, it
50
+ will switch the tag from `autorelease: tagged` to `autorelease: published`.
51
+ If this job seems to be malfunctioning, find the logs under the kokoro job
52
+ `cloud-devrel/ruby/functions-framework-ruby/release`.
53
+
54
+ ## Manually proposing a release
55
+
56
+ If you want to propose a release out-of-band or customize the version number to
57
+ use, you can use a command line tool to create a release pull request.
58
+
59
+ ### Prerequisites
60
+
61
+ You need to install:
62
+
63
+ * git version 2.22 or later
64
+ * The gh cli (https://cli.github.com/)
65
+ * The release-please npm module
66
+ * The toys rubygem
67
+
68
+ ### Running the release proposal script
69
+
70
+ Once the prerequisites are installed, run:
71
+
72
+ toys release please functions_framework:1.2.3
73
+
74
+ (Replace `1.2.3` with the version to release.)
75
+
76
+ This will open an appropriate release pull request. Then you can merge it
77
+ (possibly after modifying the changelog) and the release pipeline will proceed
78
+ as described above.
@@ -147,8 +147,8 @@ command may ask you for permission to enable the Cloud Build API for the project
147
147
  if it isn't already enabled.
148
148
 
149
149
  Because you provide your own Docker image when deploying to Cloud Run, you can
150
- use any version of Ruby supported by the Functions Framework, from 2.5 through
151
- 3.0.
150
+ use any version of Ruby supported by the Functions Framework, from 2.6 through
151
+ 3.1.
152
152
 
153
153
  ### Deploying an image to Cloud Run
154
154
 
data/docs/overview.md CHANGED
@@ -46,14 +46,14 @@ requiring an HTTP server or complicated request handling logic.
46
46
 
47
47
  ## Supported Ruby versions
48
48
 
49
- This library is supported on Ruby 2.5+.
49
+ This library is supported on Ruby 2.6+.
50
50
 
51
51
  Google provides official support for Ruby versions that are actively supported
52
52
  by Ruby Core—that is, Ruby versions that are either in normal maintenance or
53
- in security maintenance, and not end of life. Currently, this means Ruby 2.5
54
- and later. Older versions of Ruby _may_ still work, but are unsupported and not
55
- recommended. See https://www.ruby-lang.org/en/downloads/branches/ for details
56
- about the Ruby support schedule.
53
+ in security maintenance, and not end of life. Older versions of Ruby _may_
54
+ still work, but are unsupported and not recommended. See
55
+ https://www.ruby-lang.org/en/downloads/branches/ for details about the Ruby
56
+ support schedule.
57
57
 
58
58
  ## Quickstart
59
59
 
@@ -85,8 +85,8 @@ module FunctionsFramework
85
85
  @source = val
86
86
  end
87
87
  op.on "--signature-type TYPE",
88
- "Asserts that the function has the given signature type." \
89
- " Supported values are 'http' and 'cloudevent'." do |val|
88
+ "Asserts that the function has the given signature type. " \
89
+ "Supported values are 'http' and 'cloudevent'." do |val|
90
90
  @signature_type = val
91
91
  end
92
92
  op.on "-p", "--port PORT", "Set the port to listen to (defaults to 8080)" do |val|
@@ -196,8 +196,8 @@ module FunctionsFramework
196
196
  function = ::FunctionsFramework.global_registry[@target]
197
197
  raise "Undefined function: #{@target.inspect}" if function.nil?
198
198
  unless @signature_type.nil? ||
199
- @signature_type == "http" && function.type == :http ||
200
- ["cloudevent", "event"].include?(@signature_type) && function.type == :cloud_event
199
+ (@signature_type == "http" && function.type == :http) ||
200
+ (["cloudevent", "event"].include?(@signature_type) && function.type == :cloud_event)
201
201
  raise "Function #{@target.inspect} does not match type #{@signature_type}"
202
202
  end
203
203
  function
@@ -200,10 +200,10 @@ module FunctionsFramework
200
200
  "providers/firebase.auth/eventTypes/user.create" => "google.firebase.auth.user.v1.created",
201
201
  "providers/firebase.auth/eventTypes/user.delete" => "google.firebase.auth.user.v1.deleted",
202
202
  "providers/google.firebase.analytics/eventTypes/event.log" => "google.firebase.analytics.log.v1.written",
203
- "providers/google.firebase.database/eventTypes/ref.create" => "google.firebase.database.document.v1.created",
204
- "providers/google.firebase.database/eventTypes/ref.write" => "google.firebase.database.document.v1.written",
205
- "providers/google.firebase.database/eventTypes/ref.update" => "google.firebase.database.document.v1.updated",
206
- "providers/google.firebase.database/eventTypes/ref.delete" => "google.firebase.database.document.v1.deleted",
203
+ "providers/google.firebase.database/eventTypes/ref.create" => "google.firebase.database.ref.v1.created",
204
+ "providers/google.firebase.database/eventTypes/ref.write" => "google.firebase.database.ref.v1.written",
205
+ "providers/google.firebase.database/eventTypes/ref.update" => "google.firebase.database.ref.v1.updated",
206
+ "providers/google.firebase.database/eventTypes/ref.delete" => "google.firebase.database.ref.v1.deleted",
207
207
  "providers/cloud.storage/eventTypes/object.change" => "google.cloud.storage.object.v1.finalized"
208
208
  }.freeze
209
209
 
@@ -87,8 +87,8 @@ module FunctionsFramework
87
87
  @server.max_threads = @config.max_threads
88
88
  @server.leak_stack_on_error = @config.show_error_details?
89
89
  @server.binder.add_tcp_listener @config.bind_addr, @config.port
90
- @config.logger.info "FunctionsFramework: Serving function #{@function.name.inspect}" \
91
- " on port #{@config.port}..."
90
+ @config.logger.info "FunctionsFramework: Serving function #{@function.name.inspect} " \
91
+ "on port #{@config.port}..."
92
92
  @server.run true
93
93
  end
94
94
  end
@@ -306,7 +306,7 @@ module FunctionsFramework
306
306
  # @return [Integer]
307
307
  #
308
308
  def max_threads
309
- @max_threads || 1
309
+ @max_threads || 16
310
310
  end
311
311
 
312
312
  ##
@@ -352,7 +352,9 @@ module FunctionsFramework
352
352
  when ::CloudEvents::CloudEventsError
353
353
  cloud_events_error_response response
354
354
  when ::StandardError
355
- error_response "#{response.class}: #{response.message}\n#{response.backtrace}\n"
355
+ message = "#{response.class}: #{response.message}"
356
+ message = [message, *response.backtrace].join "\n\t"
357
+ error_response message
356
358
  else
357
359
  error_response "Unexpected response type: #{response.class}"
358
360
  end
@@ -362,6 +364,10 @@ module FunctionsFramework
362
364
  string_response "Not found", 404
363
365
  end
364
366
 
367
+ def no_content_response
368
+ [204, [], []]
369
+ end
370
+
365
371
  def string_response string, status, content_type: nil
366
372
  string.force_encoding ::Encoding::ASCII_8BIT unless string.valid_encoding?
367
373
  if string.encoding == ::Encoding::ASCII_8BIT
@@ -387,6 +393,11 @@ module FunctionsFramework
387
393
  message = "Unexpected internal error" unless @config.show_error_details?
388
394
  string_response message, 500
389
395
  end
396
+
397
+ def flush_streams
398
+ $stdout.flush
399
+ $stderr.flush
400
+ end
390
401
  end
391
402
 
392
403
  ## @private
@@ -401,7 +412,7 @@ module FunctionsFramework
401
412
  return notfound_response if excluded_path? env
402
413
  response =
403
414
  begin
404
- logger = env["rack.logger"] ||= @config.logger
415
+ logger = env[::Rack::RACK_LOGGER] ||= @config.logger
405
416
  request = ::Rack::Request.new env
406
417
  logger.info "FunctionsFramework: Handling HTTP #{request.request_method} request"
407
418
  @function.call request, globals: @globals, logger: logger
@@ -409,6 +420,8 @@ module FunctionsFramework
409
420
  e
410
421
  end
411
422
  interpret_response response
423
+ ensure
424
+ flush_streams
412
425
  end
413
426
  end
414
427
 
@@ -424,7 +437,8 @@ module FunctionsFramework
424
437
 
425
438
  def call env
426
439
  return notfound_response if excluded_path? env
427
- logger = env["rack.logger"] ||= @config.logger
440
+ return no_content_response if env[::Rack::REQUEST_METHOD] == "GET"
441
+ logger = env[::Rack::RACK_LOGGER] ||= @config.logger
428
442
  event = decode_event env
429
443
  response =
430
444
  case event
@@ -438,6 +452,8 @@ module FunctionsFramework
438
452
  raise "Unexpected event type: #{event.class}"
439
453
  end
440
454
  interpret_response response
455
+ ensure
456
+ flush_streams
441
457
  end
442
458
 
443
459
  private
@@ -446,9 +462,8 @@ module FunctionsFramework
446
462
  begin
447
463
  @cloud_events.decode_event env
448
464
  rescue ::CloudEvents::NotCloudEventError
449
- env["rack.input"].rewind rescue nil
450
- @legacy_events.decode_rack_env(env) ||
451
- raise(::CloudEvents::CloudEventsError, "Unrecognized event format")
465
+ env[::Rack::RACK_INPUT].rewind rescue nil
466
+ @legacy_events.decode_rack_env(env) || ::CloudEvents::CloudEventsError.new("Unrecognized event format")
452
467
  end
453
468
  rescue ::CloudEvents::CloudEventsError => e
454
469
  e
@@ -335,7 +335,8 @@ module FunctionsFramework
335
335
  json = ::JSON.dump response
336
336
  string_response json, 200, content_type: "application/json"
337
337
  when ::StandardError
338
- message = "#{response.class}: #{response.message}\n#{response.backtrace}\n"
338
+ message = "#{response.class}: #{response.message}"
339
+ message = [message, *response.backtrace].join "\n\t"
339
340
  string_response message, 500
340
341
  else
341
342
  raise "Unexpected response type: #{response.inspect}"
@@ -17,5 +17,5 @@ module FunctionsFramework
17
17
  # Version of the Ruby Functions Framework
18
18
  # @return [String]
19
19
  #
20
- VERSION = "1.0.0".freeze
20
+ VERSION = "1.2.0".freeze
21
21
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: functions_framework
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Azuma
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-07-07 00:00:00.000000000 Z
11
+ date: 2022-08-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cloud_events
@@ -16,7 +16,7 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.5.1
19
+ version: 0.7.0
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
22
  version: 2.a
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: 0.5.1
29
+ version: 0.7.0
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: 2.a
@@ -80,6 +80,7 @@ files:
80
80
  - CHANGELOG.md
81
81
  - LICENSE
82
82
  - README.md
83
+ - RELEASING.md
83
84
  - bin/functions-framework
84
85
  - bin/functions-framework-ruby
85
86
  - docs/deploying-functions.md
@@ -99,10 +100,10 @@ homepage: https://github.com/GoogleCloudPlatform/functions-framework-ruby
99
100
  licenses:
100
101
  - Apache-2.0
101
102
  metadata:
102
- changelog_uri: https://googlecloudplatform.github.io/functions-framework-ruby/v1.0.0/file.CHANGELOG.html
103
+ changelog_uri: https://googlecloudplatform.github.io/functions-framework-ruby/v1.2.0/file.CHANGELOG.html
103
104
  source_code_uri: https://github.com/GoogleCloudPlatform/functions-framework-ruby
104
105
  bug_tracker_uri: https://github.com/GoogleCloudPlatform/functions-framework-ruby/issues
105
- documentation_uri: https://googlecloudplatform.github.io/functions-framework-ruby/v1.0.0
106
+ documentation_uri: https://googlecloudplatform.github.io/functions-framework-ruby/v1.2.0
106
107
  post_install_message:
107
108
  rdoc_options: []
108
109
  require_paths:
@@ -111,14 +112,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
111
112
  requirements:
112
113
  - - ">="
113
114
  - !ruby/object:Gem::Version
114
- version: 2.5.0
115
+ version: 2.6.0
115
116
  required_rubygems_version: !ruby/object:Gem::Requirement
116
117
  requirements:
117
118
  - - ">="
118
119
  - !ruby/object:Gem::Version
119
120
  version: '0'
120
121
  requirements: []
121
- rubygems_version: 3.1.6
122
+ rubygems_version: 3.3.14
122
123
  signing_key:
123
124
  specification_version: 4
124
125
  summary: Functions Framework for Ruby