а
а
CC#
Created by а on 12/6/2023 in #help
Specific load balancer
No description
5 replies
CC#
Created by а on 6/11/2023 in #help
✅ How to correctly implement a lobby system with Redis?
I am making a web game using SignalR and am looking to scale horizontally. Right now I'm designing a service to create, delete, and connect to a lobby. I want to make it possible for 1 player to be in only 1 lobby at the moment. I chose Redis as the storage for this. How should I describe player and lobby states using Redis features? I had an idea to make two key-value stores, one that will store the id of the lobby to which the player is connected by player id. And in the second repository for the lobby ID, store the json description of the lobby (name, password). But in this case, I have the following problems: how to generate a unique ID for the lobby using redis? And maybe there is a way using some data structures to make a quick search for all the players in the same lobby? (faster than O(n))? Or might it be worth storing the state in a completely different way?
4 replies
CC#
Created by а on 6/7/2023 in #help
✅ The best database for fast add/delete operations
Hello. I'm building a SignalR application that will scale horizontally. I need external storage where I can quickly add and remove temporary entries. For example, store information about which chat the user is currently in (key-value structure). Which solution should be chosen for this? It is important for me to quickly add / remove for not very large amounts of data.
5 replies
CC#
Created by а on 6/1/2023 in #help
✅ Thread-safe facade.
I'm making a realtime parser, that will read values from websocket connection and update a facade object. If I will write values in facade class without any lock statements(directly, without using multiple statements methods), could am I catch any sort of thread errors? I suppose that change/read operations from field/attribute is atmoic operation, is it truth? If is not, how I can implement this behaviuor correctly?
3 replies
CC#
Created by а on 5/7/2023 in #help
✅ Best practice with EF Core "constants"?
How to work with user groups correctly: I have a User relation that contains the id of the group in which it is located. By default, there are two user roles: User with id 1 and Admin with id 2. There are services that need to know which group a user of these two is in. How to properly organize it? Create a constant with the id of the user role and the id of the admin role and pass it throughout the application? Or create a constant with the name of the role, and each time look for the ID of this role by name? Or are there better ways to deal with this?
10 replies
CC#
Created by а on 5/6/2023 in #help
✅ REST Create-endpoint best practice.
I am creating an endpoint to add a user. The Users table is related with the Roles table. How should I implement the transfer of the user's role: accept a string with the name of the role, and throw an error if there is no such role? Or accept role id and have an endpoint to get all roles?
5 replies
CC#
Created by а on 4/23/2023 in #help
✅ Replace regex-pattern with dynamically generated string.
I have a text and a regex pattern. I want to take each of the substrings that match the pattern and replace them NOT with a constant string, but with a dynamically generated string from a method. For example, so that all occurrences are IEnumerable and I can use .Select()) to change each one so that they are overwritten in the initial text in the correct order. How can I do this?
3 replies
CC#
Created by а on 4/22/2023 in #help
❔ Regex split
I have a string with format "[ANY_TEXT][ANY_TEXT] ANY_TEXT." How I can split this text in 3 variables: leftPart, middlePart, rightPart ?
4 replies
CC#
Created by а on 4/21/2023 in #help
Controller-Service architecture. What is service?
I'm developing an ASP.NET REST API and use the Controller-Service architecture (I don't have a data layer). And I have the following question: what is a service? Is it a facade object for the controller? In this case, I have two main groups of objects: Services and Controllers, each of which is in its own namespace(folder), where, in this case, should I put the rest of the classes that the service uses? In 'Model'? In 'Core'?
6 replies
CC#
Created by а on 4/20/2023 in #help
❔ What is the best approach for a process ConcurrentQueue?
I have a ConcurrentQueue which is filled by different threads. There is also a class that should, while there are elements in the queue, get the front one and process it. What is the best way to implement this? I only have this idea: In a loop with a timer, check if there are elements in the queue and if so, start processing the queue. Is there a better approach?
5 replies
CC#
Created by а on 4/20/2023 in #help
Is ASP.NET Core requests handling multi-threaded?
Do I understand correctly that requests may be processed in different threads? For example, if I have a singleton queue should I use a ConcurrentQueue<T> instead of Queue<T> for that?
3 replies
CC#
Created by а on 8/23/2022 in #help
ASP NET Core default DI-Container, how pass in constructor not-registered parameter? [Answered]
I want to create a Model class using a DI container, services registered in the container are passed to its constructor, and a structure is passed that becomes known only in runtime.How can I make this model class created by the container? In Ninject, I used a Factory Interface for this, how can I implement this in a standard ASP NET Core container? Once again, I want to i can create Model like that: _modelFactory.Create(data);
public class Model
{
// ITimeService registered in container, data not registered ( creating in runtime )
public Model(ITimeService timeService, EngineData data)
{

}
}
public class Model
{
// ITimeService registered in container, data not registered ( creating in runtime )
public Model(ITimeService timeService, EngineData data)
{

}
}
7 replies