1

When an issue is created in GitHub it has a unique identifier (like #1532) within a repository. How to implement this mechanism in a microservice architecture? Suppose I have 2 services Facilities and Issues, when an issue is created it must have a unique human-readable code within a certain facility.

I think that each time calling Facilities microservice to know the last code number is not a good idea.

Right now I'm thinking about using a queue like rabbitmq which would hold a facilityId and the last error code and update it every time the the code is requested.

I'm not quite sure about all the cons of such approach. Are there other better ways of solving this problem? Any help would be appreciated

UPDATE

I was also thinking about just storing facility ids and last codes in the database with initial values which seems like a good idea now

Le garcon
  • 7,197
  • 9
  • 31
  • 46

2 Answers2

0

Id generation in distributed system is a problem which has been around for a while.

Being human friendly excludes the simplest approach of using uuids...

I'd personally advise not to implement it yourself, there are probably multiple tools in the wild solving it for example the id generator of apache ignite.

Gab
  • 7,869
  • 4
  • 37
  • 68
0

There are a few options here

  • Ask Facility synchronously for an issue number at each issue creation. See tradeoffs here.
  • Store a map of (Facility, IssueId) in the Issues microservice with some kind of auto increment logic. This requires Issues to be notified of Facility changes. See tradeoffs there.
  • Make Facility the source of Issue creation. Might be smarter if there are other side effects in the Facility service of opening an issue.
guillaume31
  • 13,738
  • 1
  • 32
  • 51