Sha256: 20a5fe19395ed74a08ad2653ab18b507ffb17d073deb3166a971f462e25ffcce

Contents?: true

Size: 787 Bytes

Versions: 1

Compression:

Stored size: 787 Bytes

Contents

require 'grpc'
require_relative 'controlclient_pb'

module Momento
  # @private
  class ListCachesResponseBuilder < ResponseBuilder
    # Build a Momento::ListCachesResponse from a block of code
    # which returns a Momento::ControlClient::ListCachesResponse..
    #
    # @return [Momento::ListCachesResponse]
    # @raise [StandardError] when the exception is not recognized.
    # @raise [TypeError] when the response is not recognized.
    def from_block
      response = yield
    rescue GRPC::BadStatus => e
      ListCachesResponse::Error.new(
        exception: e, context: context
      )
    else
      raise TypeError unless response.is_a?(::Momento::ControlClient::ListCachesResponse)

      return ListCachesResponse::Success.new(grpc_response: response)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
momento-0.2.0 lib/momento/list_caches_response_builder.rb