channel_state_client.rb 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/usr/bin/env ruby
  2. # Copyright 2015 gRPC authors.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. require_relative './end2end_common'
  16. def main
  17. server_port = ''
  18. OptionParser.new do |opts|
  19. opts.on('--client_control_port=P', String) do
  20. STDERR.puts 'client_control_port ignored'
  21. end
  22. opts.on('--server_port=P', String) do |p|
  23. server_port = p
  24. end
  25. end.parse!
  26. ch = GRPC::Core::Channel.new("localhost:#{server_port}", {},
  27. :this_channel_is_insecure)
  28. loop do
  29. state = ch.connectivity_state
  30. ch.watch_connectivity_state(state, Time.now + 360)
  31. end
  32. end
  33. main