...

Source file src/cloud.google.com/go/rpcreplay/example_test.go

Documentation: cloud.google.com/go/rpcreplay

     1  // Copyright 2017 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  //      http://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  
    15  package rpcreplay_test
    16  
    17  import (
    18  	"cloud.google.com/go/rpcreplay"
    19  	"google.golang.org/grpc"
    20  )
    21  
    22  var serverAddress string
    23  
    24  func Example_NewRecorder() {
    25  	rec, err := rpcreplay.NewRecorder("service.replay", nil)
    26  	if err != nil {
    27  		// TODO: Handle error.
    28  	}
    29  	defer func() {
    30  		if err := rec.Close(); err != nil {
    31  			// TODO: Handle error.
    32  		}
    33  	}()
    34  	conn, err := grpc.Dial(serverAddress, rec.DialOptions()...)
    35  	if err != nil {
    36  		// TODO: Handle error.
    37  	}
    38  	_ = conn // TODO: use connection
    39  }
    40  
    41  func Example_NewReplayer() {
    42  	rep, err := rpcreplay.NewReplayer("service.replay")
    43  	if err != nil {
    44  		// TODO: Handle error.
    45  	}
    46  	defer rep.Close()
    47  	conn, err := grpc.Dial(serverAddress, rep.DialOptions()...)
    48  	if err != nil {
    49  		// TODO: Handle error.
    50  	}
    51  	_ = conn // TODO: use connection
    52  }
    53  

View as plain text