1 | import { StatusObject } from './call-interface';
|
2 | import { Metadata } from './metadata';
|
3 | import { Status } from './constants';
|
4 | import { LoadBalancer } from './load-balancer';
|
5 | import { SubchannelInterface } from './subchannel-interface';
|
6 | export declare enum PickResultType {
|
7 | COMPLETE = 0,
|
8 | QUEUE = 1,
|
9 | TRANSIENT_FAILURE = 2,
|
10 | DROP = 3
|
11 | }
|
12 | export interface PickResult {
|
13 | pickResultType: PickResultType;
|
14 | |
15 |
|
16 |
|
17 |
|
18 |
|
19 | subchannel: SubchannelInterface | null;
|
20 | |
21 |
|
22 |
|
23 |
|
24 | status: StatusObject | null;
|
25 | onCallStarted: (() => void) | null;
|
26 | onCallEnded: ((statusCode: Status) => void) | null;
|
27 | }
|
28 | export interface CompletePickResult extends PickResult {
|
29 | pickResultType: PickResultType.COMPLETE;
|
30 | subchannel: SubchannelInterface | null;
|
31 | status: null;
|
32 | onCallStarted: (() => void) | null;
|
33 | onCallEnded: ((statusCode: Status) => void) | null;
|
34 | }
|
35 | export interface QueuePickResult extends PickResult {
|
36 | pickResultType: PickResultType.QUEUE;
|
37 | subchannel: null;
|
38 | status: null;
|
39 | onCallStarted: null;
|
40 | onCallEnded: null;
|
41 | }
|
42 | export interface TransientFailurePickResult extends PickResult {
|
43 | pickResultType: PickResultType.TRANSIENT_FAILURE;
|
44 | subchannel: null;
|
45 | status: StatusObject;
|
46 | onCallStarted: null;
|
47 | onCallEnded: null;
|
48 | }
|
49 | export interface DropCallPickResult extends PickResult {
|
50 | pickResultType: PickResultType.DROP;
|
51 | subchannel: null;
|
52 | status: StatusObject;
|
53 | onCallStarted: null;
|
54 | onCallEnded: null;
|
55 | }
|
56 | export interface PickArgs {
|
57 | metadata: Metadata;
|
58 | extraPickInfo: {
|
59 | [key: string]: string;
|
60 | };
|
61 | }
|
62 | /**
|
63 | * A proxy object representing the momentary state of a load balancer. Picks
|
64 | * subchannels or returns other information based on that state. Should be
|
65 | * replaced every time the load balancer changes state.
|
66 | */
|
67 | export interface Picker {
|
68 | pick(pickArgs: PickArgs): PickResult;
|
69 | }
|
70 | /**
|
71 | * A standard picker representing a load balancer in the TRANSIENT_FAILURE
|
72 | * state. Always responds to every pick request with an UNAVAILABLE status.
|
73 | */
|
74 | export declare class UnavailablePicker implements Picker {
|
75 | private status;
|
76 | constructor(status?: Partial<StatusObject>);
|
77 | pick(pickArgs: PickArgs): TransientFailurePickResult;
|
78 | }
|
79 | /**
|
80 | * A standard picker representing a load balancer in the IDLE or CONNECTING
|
81 | * state. Always responds to every pick request with a QUEUE pick result
|
82 | * indicating that the pick should be tried again with the next `Picker`. Also
|
83 | * reports back to the load balancer that a connection should be established
|
84 | * once any pick is attempted.
|
85 | * If the childPicker is provided, delegate to it instead of returning the
|
86 | * hardcoded QUEUE pick result, but still calls exitIdle.
|
87 | */
|
88 | export declare class QueuePicker {
|
89 | private loadBalancer;
|
90 | private childPicker?;
|
91 | private calledExitIdle;
|
92 | constructor(loadBalancer: LoadBalancer, childPicker?: Picker | undefined);
|
93 | pick(pickArgs: PickArgs): PickResult;
|
94 | }
|
95 |
|
\ | No newline at end of file |