You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
=== Using the Client in a Function-as-a-Service Environment
152
+
153
+
This section illustrates the best practices for leveraging the {es} client in a Function-as-a-Service (FaaS) environment. The most influential optimization is to initialize the client outside of the function, the global scope. This practice does not only improve performance but also enables background functionality as – for example – sniffing. The following examples provide a skeleton for the best practices.
154
+
155
+
[discrete]
156
+
==== GCP Cloud Functions
157
+
158
+
[source,ruby]
159
+
------------------------------------
160
+
require 'functions_framework'
161
+
require 'elasticsearch'
162
+
163
+
client = Elasticsearch::Client.new(
164
+
cloud_id: "elasic-cloud-id",
165
+
user: "elastic",
166
+
password: "password",
167
+
log: true
168
+
)
169
+
170
+
FunctionsFramework.http "hello_world" do |request|
0 commit comments