You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

218 lines
8.8 KiB

  1. // Copyright 2018 Google LLC
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // https://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. // AUTO-GENERATED CODE. DO NOT EDIT.
  15. package debugger
  16. import (
  17. "time"
  18. "cloud.google.com/go/internal/version"
  19. gax "github.com/googleapis/gax-go"
  20. "golang.org/x/net/context"
  21. "google.golang.org/api/option"
  22. "google.golang.org/api/transport"
  23. clouddebuggerpb "google.golang.org/genproto/googleapis/devtools/clouddebugger/v2"
  24. "google.golang.org/grpc"
  25. "google.golang.org/grpc/codes"
  26. "google.golang.org/grpc/metadata"
  27. )
  28. // Controller2CallOptions contains the retry settings for each method of Controller2Client.
  29. type Controller2CallOptions struct {
  30. RegisterDebuggee []gax.CallOption
  31. ListActiveBreakpoints []gax.CallOption
  32. UpdateActiveBreakpoint []gax.CallOption
  33. }
  34. func defaultController2ClientOptions() []option.ClientOption {
  35. return []option.ClientOption{
  36. option.WithEndpoint("clouddebugger.googleapis.com:443"),
  37. option.WithScopes(DefaultAuthScopes()...),
  38. }
  39. }
  40. func defaultController2CallOptions() *Controller2CallOptions {
  41. retry := map[[2]string][]gax.CallOption{
  42. {"default", "idempotent"}: {
  43. gax.WithRetry(func() gax.Retryer {
  44. return gax.OnCodes([]codes.Code{
  45. codes.DeadlineExceeded,
  46. codes.Unavailable,
  47. }, gax.Backoff{
  48. Initial: 100 * time.Millisecond,
  49. Max: 60000 * time.Millisecond,
  50. Multiplier: 1.3,
  51. })
  52. }),
  53. },
  54. }
  55. return &Controller2CallOptions{
  56. RegisterDebuggee: retry[[2]string{"default", "non_idempotent"}],
  57. ListActiveBreakpoints: retry[[2]string{"default", "idempotent"}],
  58. UpdateActiveBreakpoint: retry[[2]string{"default", "idempotent"}],
  59. }
  60. }
  61. // Controller2Client is a client for interacting with Stackdriver Debugger API.
  62. //
  63. // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
  64. type Controller2Client struct {
  65. // The connection to the service.
  66. conn *grpc.ClientConn
  67. // The gRPC API client.
  68. controller2Client clouddebuggerpb.Controller2Client
  69. // The call options for this service.
  70. CallOptions *Controller2CallOptions
  71. // The x-goog-* metadata to be sent with each request.
  72. xGoogMetadata metadata.MD
  73. }
  74. // NewController2Client creates a new controller2 client.
  75. //
  76. // The Controller service provides the API for orchestrating a collection of
  77. // debugger agents to perform debugging tasks. These agents are each attached
  78. // to a process of an application which may include one or more replicas.
  79. //
  80. // The debugger agents register with the Controller to identify the application
  81. // being debugged, the Debuggee. All agents that register with the same data,
  82. // represent the same Debuggee, and are assigned the same debuggee_id.
  83. //
  84. // The debugger agents call the Controller to retrieve the list of active
  85. // Breakpoints. Agents with the same debuggee_id get the same breakpoints
  86. // list. An agent that can fulfill the breakpoint request updates the
  87. // Controller with the breakpoint result. The controller selects the first
  88. // result received and discards the rest of the results.
  89. // Agents that poll again for active breakpoints will no longer have
  90. // the completed breakpoint in the list and should remove that breakpoint from
  91. // their attached process.
  92. //
  93. // The Controller service does not provide a way to retrieve the results of
  94. // a completed breakpoint. This functionality is available using the Debugger
  95. // service.
  96. func NewController2Client(ctx context.Context, opts ...option.ClientOption) (*Controller2Client, error) {
  97. conn, err := transport.DialGRPC(ctx, append(defaultController2ClientOptions(), opts...)...)
  98. if err != nil {
  99. return nil, err
  100. }
  101. c := &Controller2Client{
  102. conn: conn,
  103. CallOptions: defaultController2CallOptions(),
  104. controller2Client: clouddebuggerpb.NewController2Client(conn),
  105. }
  106. c.SetGoogleClientInfo()
  107. return c, nil
  108. }
  109. // Connection returns the client's connection to the API service.
  110. func (c *Controller2Client) Connection() *grpc.ClientConn {
  111. return c.conn
  112. }
  113. // Close closes the connection to the API service. The user should invoke this when
  114. // the client is no longer required.
  115. func (c *Controller2Client) Close() error {
  116. return c.conn.Close()
  117. }
  118. // SetGoogleClientInfo sets the name and version of the application in
  119. // the `x-goog-api-client` header passed on each request. Intended for
  120. // use by Google-written clients.
  121. func (c *Controller2Client) SetGoogleClientInfo(keyval ...string) {
  122. kv := append([]string{"gl-go", version.Go()}, keyval...)
  123. kv = append(kv, "gapic", version.Repo, "gax", gax.Version, "grpc", grpc.Version)
  124. c.xGoogMetadata = metadata.Pairs("x-goog-api-client", gax.XGoogHeader(kv...))
  125. }
  126. // RegisterDebuggee registers the debuggee with the controller service.
  127. //
  128. // All agents attached to the same application must call this method with
  129. // exactly the same request content to get back the same stable debuggee_id.
  130. // Agents should call this method again whenever google.rpc.Code.NOT_FOUND
  131. // is returned from any controller method.
  132. //
  133. // This protocol allows the controller service to disable debuggees, recover
  134. // from data loss, or change the debuggee_id format. Agents must handle
  135. // debuggee_id value changing upon re-registration.
  136. func (c *Controller2Client) RegisterDebuggee(ctx context.Context, req *clouddebuggerpb.RegisterDebuggeeRequest, opts ...gax.CallOption) (*clouddebuggerpb.RegisterDebuggeeResponse, error) {
  137. ctx = insertMetadata(ctx, c.xGoogMetadata)
  138. opts = append(c.CallOptions.RegisterDebuggee[0:len(c.CallOptions.RegisterDebuggee):len(c.CallOptions.RegisterDebuggee)], opts...)
  139. var resp *clouddebuggerpb.RegisterDebuggeeResponse
  140. err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  141. var err error
  142. resp, err = c.controller2Client.RegisterDebuggee(ctx, req, settings.GRPC...)
  143. return err
  144. }, opts...)
  145. if err != nil {
  146. return nil, err
  147. }
  148. return resp, nil
  149. }
  150. // ListActiveBreakpoints returns the list of all active breakpoints for the debuggee.
  151. //
  152. // The breakpoint specification (location, condition, and expressions
  153. // fields) is semantically immutable, although the field values may
  154. // change. For example, an agent may update the location line number
  155. // to reflect the actual line where the breakpoint was set, but this
  156. // doesn't change the breakpoint semantics.
  157. //
  158. // This means that an agent does not need to check if a breakpoint has changed
  159. // when it encounters the same breakpoint on a successive call.
  160. // Moreover, an agent should remember the breakpoints that are completed
  161. // until the controller removes them from the active list to avoid
  162. // setting those breakpoints again.
  163. func (c *Controller2Client) ListActiveBreakpoints(ctx context.Context, req *clouddebuggerpb.ListActiveBreakpointsRequest, opts ...gax.CallOption) (*clouddebuggerpb.ListActiveBreakpointsResponse, error) {
  164. ctx = insertMetadata(ctx, c.xGoogMetadata)
  165. opts = append(c.CallOptions.ListActiveBreakpoints[0:len(c.CallOptions.ListActiveBreakpoints):len(c.CallOptions.ListActiveBreakpoints)], opts...)
  166. var resp *clouddebuggerpb.ListActiveBreakpointsResponse
  167. err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  168. var err error
  169. resp, err = c.controller2Client.ListActiveBreakpoints(ctx, req, settings.GRPC...)
  170. return err
  171. }, opts...)
  172. if err != nil {
  173. return nil, err
  174. }
  175. return resp, nil
  176. }
  177. // UpdateActiveBreakpoint updates the breakpoint state or mutable fields.
  178. // The entire Breakpoint message must be sent back to the controller service.
  179. //
  180. // Updates to active breakpoint fields are only allowed if the new value
  181. // does not change the breakpoint specification. Updates to the location,
  182. // condition and expressions fields should not alter the breakpoint
  183. // semantics. These may only make changes such as canonicalizing a value
  184. // or snapping the location to the correct line of code.
  185. func (c *Controller2Client) UpdateActiveBreakpoint(ctx context.Context, req *clouddebuggerpb.UpdateActiveBreakpointRequest, opts ...gax.CallOption) (*clouddebuggerpb.UpdateActiveBreakpointResponse, error) {
  186. ctx = insertMetadata(ctx, c.xGoogMetadata)
  187. opts = append(c.CallOptions.UpdateActiveBreakpoint[0:len(c.CallOptions.UpdateActiveBreakpoint):len(c.CallOptions.UpdateActiveBreakpoint)], opts...)
  188. var resp *clouddebuggerpb.UpdateActiveBreakpointResponse
  189. err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  190. var err error
  191. resp, err = c.controller2Client.UpdateActiveBreakpoint(ctx, req, settings.GRPC...)
  192. return err
  193. }, opts...)
  194. if err != nil {
  195. return nil, err
  196. }
  197. return resp, nil
  198. }