Sha256: 2901e62687a15467d57c9d60824b5b99ff7da5710f10c230aeab9157d9e21cb2

Contents?: true

Size: 855 Bytes

Versions: 1

Compression:

Stored size: 855 Bytes

Contents

require 'grpc'
require_relative 'controlclient_pb'

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

      return CreateCacheResponse::Success.new
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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