zobweyt
zobweyt
Explore posts from servers
CC#
Created by zobweyt on 4/12/2024 in #help
Attributes confusion
anyway, thank you so much for the suggestion! I'll try to implement something similar and compare it with other ideas :)
21 replies
CC#
Created by zobweyt on 4/12/2024 in #help
Attributes confusion
yeah, I'm of the same opinion, but the framework which I use decides the attributes interaction for me
21 replies
CC#
Created by zobweyt on 4/12/2024 in #help
Attributes confusion
also, all of these attributes will always be executed before processing the request until there is a negative result or all attributes check the conditions (this is because of the framework's nature for which I am trying to implement it). because of this, there may be conflicts: for example, I have this method:
[RateLimit<AdminPolicy>]
[RateLimit<DefaultPolicy>]
public static void Foo() => throw NotImplementedException();
[RateLimit<AdminPolicy>]
[RateLimit<DefaultPolicy>]
public static void Foo() => throw NotImplementedException();
although AdminPolicy skips all requests, the following attribute is always executed after it, which will be valid for all requests
21 replies
CC#
Created by zobweyt on 4/12/2024 in #help
Attributes confusion
speaking globally, what would you prefer as a user of it? pass policies into one attribute as the argument, thereby making the string infinitely long and unreadable, or make several such attributes that accept the policy as a generic argument creating a long chain of attributes on several lines?
21 replies
CC#
Created by zobweyt on 4/12/2024 in #help
Attributes confusion
well, it seems to be more customizable
21 replies
CC#
Created by zobweyt on 4/12/2024 in #help
Attributes confusion
maybe I can do a DefaultPolicy and use it like that [RateLimit<DefaultPolicy>]
21 replies
CC#
Created by zobweyt on 4/12/2024 in #help
Attributes confusion
if there's no policy, then the rate limit should be applied to every request (which is the default policy)
21 replies
CC#
Created by zobweyt on 4/12/2024 in #help
Attributes confusion
however, maybe I still need to rework the core attribute logic to make this possible
21 replies
CC#
Created by zobweyt on 4/12/2024 in #help
Attributes confusion
if I allow to use multiple [RateLimit] attributes, then there will be multiple PartitionedRateLimiter instances, so the logic might be duplicated
21 replies
CC#
Created by zobweyt on 4/12/2024 in #help
Attributes confusion
I thought about this too, but what if you need multiple policies? also, you won't be able to use the [RateLimit] without the generic type
21 replies
CC#
Created by zobweyt on 4/12/2024 in #help
Attributes confusion
thank you!! I'll look into it :)
21 replies
CC#
Created by zobweyt on 4/12/2024 in #help
Attributes confusion
or should I just do it like that:
if (type is not BaseType baseType)
throw Exception();

baseType.MyMethod();
if (type is not BaseType baseType)
throw Exception();

baseType.MyMethod();
21 replies
CC#
Created by zobweyt on 4/12/2024 in #help
Attributes confusion
these are user defined (not constants) as for the list of types, how do you type them correctly? for example, just Type[] policies? but how do you get the needed method to execute without hard-coding its name in a string? I was trying to find something like "generic type" so I could use it like that: Type<BaseType>[] policies
21 replies
CC#
Created by zobweyt on 1/25/2024 in #help
Implementing rate limiting for discord bot interactions with absolute expiration of items
Also, I thought about using polymorphism instead of IgnoreTargets, but I couldn’t get to a good and working implementation
5 replies
CC#
Created by zobweyt on 1/25/2024 in #help
Implementing rate limiting for discord bot interactions with absolute expiration of items
And here is implementation using MemoryCache
5 replies
CC#
Created by zobweyt on 1/25/2024 in #help
Implementing rate limiting for discord bot interactions with absolute expiration of items
So here I tried to implement this using System.Threading.RateLimiting
5 replies
CC#
Created by zobweyt on 7/16/2023 in #help
✅ What is the best way to setup app configuration using IHostBuilder?
thank you, I got it!
6 replies
CC#
Created by zobweyt on 12/23/2022 in #help
❔ Naming fields meaning numbers
oh right, thank you!
6 replies