mirror of https://github.com/grpc/grpc-node.git
				
				
				
			JS: Add initial metadata options API compatibility
This commit is contained in:
		
							parent
							
								
									fe090a089a
								
							
						
					
					
						commit
						d4e1672071
					
				|  | @ -18,6 +18,7 @@ HTTP Connect Support | :heavy_check_mark: | :x: | |||
| Retries | :heavy_check_mark: | :x: | ||||
| Stats/tracing/monitoring | :heavy_check_mark: | :x: | ||||
| Load Balancing | :heavy_check_mark: | :x: | ||||
| Initial Metadata Options | :heavy_check_mark: | :x: | ||||
| 
 | ||||
| Other Properties | `grpc` | `@grpc/grpc-js` | ||||
| -----------------|--------|---------------- | ||||
|  |  | |||
|  | @ -44,12 +44,27 @@ function validate(key: string, value?: MetadataValue): void { | |||
|   } | ||||
| } | ||||
| 
 | ||||
| interface MetadataOptions { | ||||
|   /* Signal that the request is idempotent. Defaults to false */ | ||||
|   idempotentRequest?: boolean; | ||||
|   /* Signal that the call should not return UNAVAILABLE before it has | ||||
|    * started. Defaults to true. */ | ||||
|   waitForReady?: boolean; | ||||
|   /* Signal that the call is cacheable. GRPC is free to use GET verb. | ||||
|    * Defaults to false */ | ||||
|   cacheableRequest?: boolean; | ||||
|   /* Signal that the initial metadata should be corked. Defaults to false. */ | ||||
|   corked?: boolean; | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  * A class for storing metadata. Keys are normalized to lowercase ASCII. | ||||
|  */ | ||||
| export class Metadata { | ||||
|   protected internalRepr: MetadataObject = new Map<string, MetadataValue[]>(); | ||||
| 
 | ||||
|   constructor(private options?: MetadataOptions) {} | ||||
| 
 | ||||
|   /** | ||||
|    * Sets the given value for the given key by replacing any other values | ||||
|    * associated with that key. Normalizes the key. | ||||
|  | @ -160,6 +175,10 @@ export class Metadata { | |||
|     }); | ||||
|   } | ||||
| 
 | ||||
|   setOptions(options: MetadataOptions) { | ||||
|     this.options = options; | ||||
|   } | ||||
| 
 | ||||
|   /** | ||||
|    * Creates an OutgoingHttpHeaders object that can be used with the http2 API. | ||||
|    */ | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue