Configuration per Fabric instance

I am creating a stateless state service that requires configuration data for each instance. My initial thought was to create named partitions and use PartitionInfo

to retrieve the named key using a generic read dictionary to load settings for each instance. The problem is that the partition key is now required for internal access to this instance (from other services). Since all sections using this method will serve the same data internally, it doesn't matter which section I connect to (I would like it to be random). So this gives me many possible ways to fix this problem:

The following solutions, which do not include sections:

  • Configuration based on each instance. This post doesn't provide much help in designing a solution. A configuration section that is unique to each instance will be the most ideal solution.
  • Create named instances and use name as username (basically appending a string to a non-segmented instance)
  • Get an instance by index and use the index on the public readable dictionary to get the username.
  • Somehow use InitializationData (see this post ) to get the username string (if InitializationData can be unique for each instance).

All of the above will solve my problem. Is such a possibility possible?

EDIT: An example of the service I'm trying to create:

Let's say we have a question service for stackoverflow (for short SOQS). For this example, assume that one user can connect to the stackoverflow web layout at any given time. Internal methods SOQS (published in my service structure) have one method: GetQuestions()

. Each SOQS will need to connect to stackoverflow with a unique username / password, and as new questions are pushed through the websocket, they are added to the internal question list. The SOQS method GetQuestions()

(called internally from my service cloth) will then provide the same list of questions. Then I can load the balance by adding multiple instances (as long as I have more username / password) and then the internal load can be distributed to my fabric. I could callServiceProxy.Create<SOQS>()

to connect to a random instance to get your list of questions.

+3


source to share


2 answers


It sounds like what you are looking for is to have a service type that has multiple actors, each with their own configuration. They would not be multiple copies of the same service with unique configurations, it would be one (with replicas, of course) service instance as a singleton, and separate principals for each instance.



As an example, you might have a custom service (guess what it is when you mention the username string), read from some external storage engine a list of usernames and longs for instance ids for each that will be used for internal tracking. The service then created its own configuration information for each actor. The User Service will then be the router for the exchange of messages between and from the individual participants.

+1


source


I'm not entirely sure if this is what you are looking for, but one alternative might be to create an additional configuration service to provide unique configurations for each instance. When starting a stateless service, you just ask for a random (or non-random) config object such as a json string and load the service during initialization. This way you don't have to mess with the partitions as each stateless instance starts its own Startup.cs (or equivalent).



+1


source







All Articles