Comments (2)
Maybe it's a good place to implement Memoization (I've never do that)..
Maybe something like this
public async Task<T> Get<T>(string path)
where T : new()
{
VaultClient client = new VaultClient(new VaultClientSettings(_vaultSettings.VaultUrl,
new TokenAuthMethodInfo(_vaultSettings.TokenApi)));
var requestFn = async (string path) => await client.V1.Secrets.KeyValue.V2.ReadSecretAsync(path: path, mountPoint: "secret");
Secret<SecretData> kv2Secret = await requestFn.ThreadSafeMemoize()(path);
var returnedData = kv2Secret.Data.Data;
return returnedData.ToObject<T>();
}
public static Func<A, R> ThreadSafeMemoize<A, R>(this Func<A, R> func)
{
return Memoizer.ThreadSafeMemoize(func);
}
public static Func<A, R> ThreadSafeMemoize<A, R>(Func<A, R> func)
{
var cache = new ConcurrentDictionary<A, R>();
return argument => cache.GetOrAdd(argument, func);
}
Of course, with this approach it's impossible to implement retries and in case of an error, the error will be in the cache and it will be the result while the application is running. I don't know, it's just a good place to practice Memoization xD
from distribt.
@AlexScigalszky nah memoization is good when you have to query something and then query it again and again, etc and you konw it will never change. in this case the issue is different.
the idea on this task is to intercept somehow the failed queries by unauthorrized and do the getconnection call then retry with the new credentials, being completly transparent to the app.
A good place for memoization is in the MongoConnectionProvider
:
the GetMongoUrl
can be done with memoization
from distribt.
Related Issues (20)
- Create shared.awaiter HOT 5
- Service Discovery: Add tests
- API Gateway: update both apis to have the config in code
- Documentation: add shared.Distribt.Discovery
- Improve the way the connection is retrieved in mongoDb
- Create basic functionality for stock and warehouse microservices
- when using aggregates the classes have to be registered
- Documentation for event sourcing and aggregates
- include host and port of graylog inside consul
- add unit testing in ProductNameService
- abstract all HttpCalls to Other microservices to a shared project
- Investigate if the aggregate GetById should return null
- Refactor to use Rop
- investigate the use of inject IMongoDatabase on the event store HOT 1
- build an inmemory configuration for the healthchecks
- kafka health check not working
- update observability URL
- Prepare the enviornment to build and run integration tests
- FormatterServices is obsolete (inside the aggretage repository
- Add new MessageModels easily HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from distribt.