Implementing basic Claim API
What does this MR do?
This MR is Addressing: gitlab-org/gitlab#469076 (closed)
In this MR, we are implementing a basic functionality for the Claims Service / Create Claim.
This MR doesn't implement:
- Persisting the Claims, or checks if the claim existed before in the system.
- All the validations. For now we do basic validation on the Attribute Types + Some tests on the Ruby client.
- HTTP Interface for Claims. As this is called from Rails Application, GRPC will suffice for now.
ClaimStore
?
What about the This is a placeholder for Claims Persistence layer / Query Interface. We haven't agreed on how to implement this functionality yet. There is an issue for this: gitlab-org/gitlab#451050
ClaimStore
is only about indicating that the service itself should not contain this functionality
in the future, but not an indication about any future internal architecture of the service.
How to validate locally?
In case you wanted to test the GRPC Interface locally. You can follow these steps.
- Run the Topology Service using
go run . serve
. If it wasn't build, build it usingmake build
before - In a separate temporary folder create a
Gemfile
that contains the following
Make sure it contains the correct Ruby Version, and the path and path of the Topology Service
Gemfile
source 'https://rubygems.org'
ruby '3.1.2'
gem 'gitlab-topology-service-client', :path => '/Users/USERNAME/.../topology-service/clients/ruby'
Create this main.rb
file, and run it using ruby main.rb
. Feel free to change the parameters and experiment with the service
main.rb
require 'bundler/setup'
require 'gitlab/cells/topology_service'
def test_with_mtls?; true; end
def file_path(file)
File.join("/Users", "omar", "topology-service", "tmp", "certs", file)
end
def service_credentials
GRPC::Core::ChannelCredentials.new(
File.read(file_path("ca-cert.pem")),
(File.read(file_path("client-key.pem")) if test_with_mtls?),
(File.read(file_path("client-cert.pem")) if test_with_mtls?)
)
end
claim_service = Gitlab::Cells::TopologyService::ClaimService::Stub.new('localhost:9095', service_credentials)
#claim_metadata = Gitlab::Cells::TopologyService.build_metadata(cell_name: "cell-1")
claim_details = Gitlab::Cells::TopologyService::ClaimDetails.new(
{
claim: {
bucket: Gitlab::Cells::TopologyService::ClaimRecord::Bucket::Routes,
value: "gitlab-org/gitlab"
},
parent: {
model: Gitlab::Cells::TopologyService::ParentRecord::ApplicationModel::Project,
id: 1
},
owner: {
table: Gitlab::Cells::TopologyService::OwnerRecord::Table::Routes,
id: 3
}
})
create_claim_request = Gitlab::Cells::TopologyService::CreateClaimRequest.new(
details: claim_details
)
response = claim_service.create_claim(create_claim_request)
puts response
What are the next possible steps for Claims?
- Integrating the TS Ruby Gem in the Rails Application gitlab-org/gitlab#451052 (closed)
- Implement basic Claims Functionality in the Rails Application gitlab-org/gitlab#455370