I'm having a problem with xe:objectData and global variables. Not sure if this is a bug or working as designed.
The sample is a dumb one, I know. It's just meant to demonstrate the issue.
works as expected
throws exception. I have seen the same behaviour, when I try to use scoped variables in xe:objectData. Always a null is returned, although the variables contain values.
Anyone to shed a light on this?
I believe you can not use bundle resources at that time because of timing of when things occur in the lifecycle. When the objectData's create object method is called, other objects may not yet be created yet. You may have to manually load the bundle and retrieve the property you need.
Related
I have a service that has a method (A.method()) which is called by other methods from multiple services (B.method(), C.method()...).
I want to know somehow what's the method caller name or the service that called my method.
The only working solution I found until know is throwing a dummy error and checking error.stack, but this is dirty :)
PS: I'm not using any controller/resolver, just functions that are starting because of cronjobs or constructors.
I tried interceptors & auth guards but it seems they do not work for simple methods.
I think the error stack is enough information.
If you find the name is ugly, then you should add sourceMap for better function name and file location.
Another approach ( maybe a bit overkill ) is to add tracing like Jaeger or OpenTelemetry to visualize the functions call, execution time and many other information.
I am currently working on trying to manage a resource with Terraform that has no delete method, and terraform insists there must be one.
1 error occurred:
* resource xray_db_sync_time: Delete must be implemented
The API I am trying to implement is here, and as you can see, there is no "Delete". You can't remove this sync timer. I am open to ideas. The code being worked on is here
This is a situation where you, as the provider developer, will need to make a judgement call about how best to handle this mismatch between Terraform's typical resource instance lifecycle and the actual lifecycle of the object type you're intending to represent.
Broadly speaking, there are two options:
You could make the Delete function immediately return an error, explaining that this object is not deleteable. This could be an appropriate approach if the user might be surprised or harmed by the object continuing to exist even though Terraform has no record of it. I would informally call this the "explicit approach", because it makes the user aware that something unusual is happening and requires them to explicitly confirm that they want Terraform to just "forget" the rather than destroying it, using terraform state rm.
You could make the Delete function just call d.SetId("") (indicating to the SDK that the object no longer exists) and return successfully without taking any other action. I'll call this the "implicit approach", because a user not paying close attention may be fooled into thinking the object was actually deleted, due to the provider not giving any feedback that it just silently discarded the object.
Both of these options have advantages and disadvantages, and so ultimately the final decision is up to you. Terraform and its SDK will support either strategy, but you will need to implement some sort of Delete function, even if it doesn't do anything, to satisfy the API contract.
You are also missing a Create for this API endpoint. With only Update and Read supported, you will need to extend Create to be the same as Update except for additionally adding the resource to the state. You can easily invoke the Update function within the Create function for this behavior.
For the delete function, this should actually be easier than you may expect. The Terraform provider SDKv2 and your resource code should automatically Read the resource prior to attempting the delete to verify that it actually exists (this probably requires no extra effort on your part without seeing the code). Then you would need to remove the resource from the state with d.SetId("") where d is of type *schema.ResourceData. However, this also automatically is invoked assuming the Delete returns no errors. Therefore, you could define a Delete that merely returns warnings or errors of an appropriate Go type. If you do not need that (and probably would not considering the minimal functionality), then you could probably just return nil. Part of this is speculation based on what your code probably looks like, but in general this all holds true.
I use a StatefulService with a IReliableDictionary.
Currently, I call StateManager.GetOrAddAsync<IReliableDictionary> everywhere I need this dictionary.
Is it best practice to call one time only StateManager.GetOrAddAsync<IReliableDictionary> in the OnOpenAsync method of StatefulService and to store the return in a member ?
It does not matter much. I've asked it to the product team an got this response:
You can cache the result of GetOrAddAsync locally but it doesn't matter since the statemanager does that for you automatically. Some folks think it's easier to keep a local, but I never do because now you have some lifecycle things to deal with (you have a ref to the thing not protected by state manger acquisition locks so you can see some different exceptions, but nothing you wouldn't have to deal with anyway).
Italic text inserted by me.
As per the official documentation here, it's not recommended to store the reliable collection references.
We don't recommended that you save references to reliable collection
instances in class member variables or properties. Special care must
be taken to ensure that the reference is set to an instance at all
times in the service lifecycle. The Reliable State Manager handles
this work for you, and it's optimized for repeat visits.
I want users to be able to submit a code to a server where it would be executed. In order to secure it, I want to specify a list of functions and macros that are approved - a user execution scope. So I am wondering whether something like this is possible in clojure. Is there any easy way how to do it or are there any libraries that help with it?
My first idea was to iterate over the submitted code snippet and check that all the symbols in there are actually allowed. But then I realized that one can easily turn a string or anything into a symbol using a code. So this approach isn't the best in general.
You should probably look at stuff like Clojail.
I am pretty sure what I am about to ask is not possible, but I am hoping experts on Code Analysis may be able to suggest a workaround.
I am trying to find a way to exclude Code Analysis warning in GlobalSuppressions.cs based on functionality. For example, I would like to disable
"Microsoft.Globalization", "CA1305:SpecifyIFormatProvider"
in ****all**** of my logging statements (I use CommonLogging facade), so signature would be something like:
Common.Logging.ILog.Trace(System.Action<Common.Logging.FormatMessageHandler>)
I would like to do this everywhere throughout the project regardless of the type, namespace, or method name....
Looking at other answers, this seems to be impossible for now...Or is it?
This is indeed not possible. When you call a method that has both an overload that accepts string and one that accepts string, IFormatProvider, this rule will trigger. And it probably should, since I expect you either want Culture Sensitive or Culture Insensitive logfiles. In which case Code Analysis forces you to make that choice.
What you could do, is write your own rule and disable this one. Or you could fix the violations and get them out of the way. A quick regex search+replace can probably fix these for you in a matter of seconds.
Or you can write one class that acts as a Proxy/Facade between your code and that of Common.Logging and which only accepts the string variant. You can then refactor your code to use your method. That way you only have to fix one violation, which will remain in the newly created facade.