question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Need guidance for resource hooks

See original GitHub issue

Description

I have been trying to get Resource Hooks working in v4.0.0-alpha3. I have followed the steps in the docs, but the hook is never hit.

The only way I have actually gotten it to work is to add an explicit call to AddScoped<IResourceHookContainer<WeatherForecast>, WeatherForecastDefinition>(), then inject the IResourceHookContainer<WeatherForecast> directly into the service. But that seems wrong - looking at the source it should be registered automatically using open generics.

I also run into problems trying to call BeforeCreate because I would then have to magically have a IAffectedResources object somehow. Which seems only to be available internally through some TypeHelper extension methods and internal derived classes.

Getting this to work is a blocker for me using this library in production code because I have to be able to authenticate and authorize at the request level.

Anyway, I have posted a simple repository that reproduces the behavior: https://github.com/crgolden/JsonApiDotNetCoreIssue. Please take a look and let me know what I’m doing wrong.

Thanks! …

Environment

  • JsonApiDotNetCore Version: 4.0.0-alpha3
  • Other Relevant Package Versions: not sure

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
maureicommented, Nov 7, 2019

@crgolden I’m waiting for #618 to be approved after which I will immediately release v4.0.0-alpha4 which you can use in your corporate projects. After that no more alpha releases, we’ll be aiming for the full release of v4 (unless new immediate bugs show up). But for that I want to completely integrate it our own corporate projects first to beta (battle) test it, and write a migration guide for people coming from v3.1

1reaction
crgoldencommented, Nov 5, 2019

@maurei Thanks for the response!

Your solution worked for the simple example I shared. Then I spent several hours banging my head against the wall trying to figure out why I still couldn’t get it to work in an existing application.

Finally, I started recreating the existing application entirely from scratch to pinpoint the issue. It turns out that, as soon as the entities are moved to a separate assembly, the resource hooks no longer work. That is a big gotcha.

I updated my sample repo to reproduce the problem. Comment the WeatherForecast in the “Entities” project and uncomment the one in the “JsonApiDotNetCoreIssue” project and the resource hooks start working again.

This would be a blocking issue for me, as I can hardly guarantee the entities will always be in the same assembly. They may even be coming from a NuGet package, etc.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Resource Hooks - Declarative GitOps CD for Kubernetes
Hooks can be any type of Kubernetes resource kind, but tend to be Pod, Job or Argo Workflows. Multiple hooks can be specified...
Read more >
ArgoCD Resource Hooks.. Helped In E2E setup
I need to create an End-2-End setup, which means that after deploying a service via ArgoCD and ensuring that the pods are operational,...
Read more >
DevOps in Argo CD — Resource Hooks - Dev Genius
In Argo CD, “resource hooks” are a feature that allows you to run additional steps (in the form of Kubernetes jobs or other...
Read more >
Proactively keep resources secure and compliant with ...
Hook Targets – Hook targets are the CloudFormation resources that you want to run a hook against. Targets can be general resources that ......
Read more >
Developing hooks - CloudFormation Command Line ...
Hooks proactively inspect the configuration of your AWS resources before provisioning. Hooks automatically inspect resources before they're provisioned.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found