Craig Tiller | eb841e2 | 2016-02-11 15:49:16 -0800 | [diff] [blame] | 1 | /* |
| 2 | * |
| 3 | * Copyright 2016, Google Inc. |
| 4 | * All rights reserved. |
| 5 | * |
| 6 | * Redistribution and use in source and binary forms, with or without |
| 7 | * modification, are permitted provided that the following conditions are |
| 8 | * met: |
| 9 | * |
| 10 | * * Redistributions of source code must retain the above copyright |
| 11 | * notice, this list of conditions and the following disclaimer. |
| 12 | * * Redistributions in binary form must reproduce the above |
| 13 | * copyright notice, this list of conditions and the following disclaimer |
| 14 | * in the documentation and/or other materials provided with the |
| 15 | * distribution. |
| 16 | * * Neither the name of Google Inc. nor the names of its |
| 17 | * contributors may be used to endorse or promote products derived from |
| 18 | * this software without specific prior written permission. |
| 19 | * |
| 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 21 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 23 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 24 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 26 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 27 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 28 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 31 | * |
| 32 | */ |
| 33 | |
Craig Tiller | 9c84fc3 | 2016-03-28 17:11:55 -0700 | [diff] [blame] | 34 | #ifndef GRPC_CORE_EXT_LB_POLICY_GRPCLB_LOAD_BALANCER_API_H |
| 35 | #define GRPC_CORE_EXT_LB_POLICY_GRPCLB_LOAD_BALANCER_API_H |
Craig Tiller | eb841e2 | 2016-02-11 15:49:16 -0800 | [diff] [blame] | 36 | |
| 37 | #include <grpc/support/slice_buffer.h> |
| 38 | |
Craig Tiller | d4c9833 | 2016-03-31 13:45:47 -0700 | [diff] [blame] | 39 | #include "src/core/ext/client_config/lb_policy_factory.h" |
Craig Tiller | 4a6dad3 | 2016-04-01 13:51:14 -0700 | [diff] [blame] | 40 | #include "src/core/ext/lb_policy/grpclb/proto/grpc/lb/v0/load_balancer.pb.h" |
Craig Tiller | eb841e2 | 2016-02-11 15:49:16 -0800 | [diff] [blame] | 41 | |
| 42 | #ifdef __cplusplus |
| 43 | extern "C" { |
| 44 | #endif |
| 45 | |
| 46 | #define GRPC_GRPCLB_SERVICE_NAME_MAX_LENGTH 128 |
| 47 | |
| 48 | typedef grpc_lb_v0_LoadBalanceRequest grpc_grpclb_request; |
| 49 | typedef grpc_lb_v0_LoadBalanceResponse grpc_grpclb_response; |
| 50 | typedef grpc_lb_v0_Server grpc_grpclb_server; |
| 51 | typedef grpc_lb_v0_Duration grpc_grpclb_duration; |
| 52 | typedef struct grpc_grpclb_serverlist { |
| 53 | grpc_grpclb_server **servers; |
| 54 | size_t num_servers; |
| 55 | grpc_grpclb_duration expiration_interval; |
| 56 | } grpc_grpclb_serverlist; |
| 57 | |
| 58 | /** Create a request for a gRPC LB service under \a lb_service_name */ |
| 59 | grpc_grpclb_request *grpc_grpclb_request_create(const char *lb_service_name); |
| 60 | |
| 61 | /** Protocol Buffers v3-encode \a request */ |
| 62 | gpr_slice grpc_grpclb_request_encode(const grpc_grpclb_request *request); |
| 63 | |
| 64 | /** Destroy \a request */ |
| 65 | void grpc_grpclb_request_destroy(grpc_grpclb_request *request); |
| 66 | |
| 67 | /** Parse (ie, decode) the bytes in \a encoded_response as a \a |
| 68 | * grpc_grpclb_response */ |
| 69 | grpc_grpclb_response *grpc_grpclb_response_parse(gpr_slice encoded_response); |
| 70 | |
| 71 | /** Destroy \a serverlist */ |
| 72 | void grpc_grpclb_destroy_serverlist(grpc_grpclb_serverlist *serverlist); |
| 73 | |
| 74 | /** Parse the list of servers from an encoded \a grpc_grpclb_response */ |
| 75 | grpc_grpclb_serverlist *grpc_grpclb_response_parse_serverlist( |
| 76 | gpr_slice encoded_response); |
| 77 | |
| 78 | /** Destroy \a response */ |
| 79 | void grpc_grpclb_response_destroy(grpc_grpclb_response *response); |
| 80 | |
| 81 | #ifdef __cplusplus |
| 82 | } |
| 83 | #endif |
| 84 | |
Craig Tiller | 9c84fc3 | 2016-03-28 17:11:55 -0700 | [diff] [blame] | 85 | #endif /* GRPC_CORE_EXT_LB_POLICY_GRPCLB_LOAD_BALANCER_API_H */ |