class StatelyDB::CoreClient

def initialize(store_id:,

Parameters:
  • no_auth (Boolean) -- Indicates that the client should not attempt to get
  • region (String) -- the region to connect to.
  • endpoint (String) -- the endpoint to connect to.
  • token_provider (StatelyDB::Common::Auth::TokenProvider) -- the token provider to use for authentication.
  • schema (Module) -- the generated Schema module to use for mapping StatelyDB Items.
  • store_id (Integer) -- the StatelyDB to use for all operations with this client.
def initialize(store_id:,
               schema:,
               token_provider: nil,
               endpoint: nil,
               region: nil,
               no_auth: false)
  if store_id.nil?
    raise StatelyDB::Error.new("store_id is required",
                               code: GRPC::Core::StatusCodes::INVALID_ARGUMENT,
                               stately_code: "InvalidArgument")
  end
  if schema.nil?
    raise StatelyDB::Error.new("schema is required",
                               code: GRPC::Core::StatusCodes::INVALID_ARGUMENT,
                               stately_code: "InvalidArgument")
  end
  endpoint = self.class.make_endpoint(endpoint:, region:)
  @channel = Common::Net.new_channel(endpoint:)
  # Make sure to use the correct endpoint for the default token provider
  @token_provider = token_provider || Common::Auth::AuthTokenProvider.new(endpoint:)
  interceptors = [Common::ErrorInterceptor.new]
  interceptors << Common::Auth::Interceptor.new(token_provider: @token_provider) unless no_auth
  @stub = Stately::Db::DatabaseService::Stub.new(nil, nil,
                                                 channel_override: @channel, interceptors:)
  @store_id = store_id.to_i
  @schema = schema
  @allow_stale = false
end