@@ -205,11 +205,9 @@ impl FaasEnvironment {
205
205
}
206
206
}
207
207
FaasEnvironmentName :: Vercel => {
208
- let url = env:: var ( "VERCEL_URL" ) . ok ( ) ;
209
208
let region = env:: var ( "VERCEL_REGION" ) . ok ( ) ;
210
209
Self {
211
210
name,
212
- url,
213
211
region,
214
212
..Self :: UNSET
215
213
}
@@ -225,24 +223,28 @@ fn var_set(name: &str) -> bool {
225
223
impl FaasEnvironmentName {
226
224
fn new ( ) -> Option < Self > {
227
225
use FaasEnvironmentName :: * ;
228
- let mut found = vec ! [ ] ;
226
+ let mut found: Option < Self > = None ;
229
227
if var_set ( "AWS_EXECUTION_ENV" ) || var_set ( "AWS_LAMBDA_RUNTIME_API" ) {
230
- found. push ( AwsLambda ) ;
228
+ found = Some ( AwsLambda ) ;
231
229
}
230
+ if var_set ( "VERCEL" ) {
231
+ // Vercel takes precedence over AwsLambda.
232
+ found = Some ( Vercel ) ;
233
+ }
234
+ // Any other conflict is treated as unset.
232
235
if var_set ( "FUNCTIONS_WORKER_RUNTIME" ) {
233
- found. push ( AzureFunc ) ;
236
+ match found {
237
+ None => found = Some ( AzureFunc ) ,
238
+ _ => return None ,
239
+ }
234
240
}
235
241
if var_set ( "K_SERVICE" ) || var_set ( "FUNCTION_NAME" ) {
236
- found. push ( GcpFunc ) ;
237
- }
238
- if var_set ( "VERCEL" ) {
239
- found. push ( Vercel ) ;
240
- }
241
- if found. len ( ) != 1 {
242
- None
243
- } else {
244
- Some ( found[ 0 ] )
242
+ match found {
243
+ None => found = Some ( GcpFunc ) ,
244
+ _ => return None ,
245
+ }
245
246
}
247
+ found
246
248
}
247
249
248
250
fn name ( & self ) -> & ' static str {
@@ -282,10 +284,6 @@ lazy_static! {
282
284
type Truncation = fn ( & mut ClientMetadata ) ;
283
285
284
286
const METADATA_TRUNCATIONS : & [ Truncation ] = & [
285
- // truncate `platform`
286
- |metadata| {
287
- metadata. platform = rustc_version_runtime:: version_meta ( ) . short_version_string ;
288
- } ,
289
287
// clear `env.*` except `name`
290
288
|metadata| {
291
289
if let Some ( env) = & mut metadata. env {
@@ -308,6 +306,10 @@ const METADATA_TRUNCATIONS: &[Truncation] = &[
308
306
|metadata| {
309
307
metadata. env = None ;
310
308
} ,
309
+ // truncate `platform`
310
+ |metadata| {
311
+ metadata. platform = rustc_version_runtime:: version_meta ( ) . short_version_string ;
312
+ } ,
311
313
] ;
312
314
313
315
/// Contains the logic needed to handshake a connection.
0 commit comments