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.

Feature Request: Allows @ZeebeVariablesAsType in handler function

See original GitHub issue

This feature should enable the possibility to get variables injected in a typed manner like this:

@ZeebeWorker(type = "foo", autoComplete = true)
public ProcessVariables handleFoo(@ZeebeTypedVariables ProcessVariables variables){
  // do whatever you need to do
  return variables;
}

Inspired by @berndruecker .

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
berndrueckercommented, Dec 21, 2021

Thanks Falko - super helpful!

“So it wouldn’t make sense to have multiple such objects. Unless, each of them is only a partial mapping, which I’m wondering how this is handled by the mapper.” --> precisely, the mapper ignores everything that is not part of the variables class, so you could create classes containing partial mappings (not sure if this is a good idea though).

Let’s do this: I’ll merge the PR now and we will have the two annotations available. And then we wait a couple of months to see it used in reality, and then we can still define a shortcut to save annotations if we feel this is important. The other way round it would also mean to have a breaking chance - which we should not do.

0reactions
falkocommented, Dec 16, 2021

I’d love to avoid the @ZeebeVariable annotation in favor of a crisp readable syntax, especially when working with many variables. What confuses me is when you say to treat “all method parameters” as “VariablesAsType” because job.getVariablesAsType(ProcessVariables.class); maps all process variables to fields/properties of the provided class. So it wouldn’t make sense to have multiple such objects. Unless, each of them is only a partial mapping, which I’m wondering how this is handled by the mapper.

Thus, my suggestion would be to use an @VariablesAsType annotation for the variables to object mapper and rather make @ZeebeVariable optional to say that all method parameters that are

  • not annotated by @ZeebeVariable
  • not the ActivatedJob
  • not the JobClient
  • not annotated with @VariablesAsType

will be treated as individual variables to be casted to the respective parameter type, e.g.

@ZeebeWorker(type = "shipOrder", autoComplete = true)
public void shipOrder(String orderId, Boolean isGift) {
  // ship the package; wrap as gift if needed ;-)
}

The object mapper would thus stick to an annotation, which is less clutter in this case because it’s only one such parameter:

@ZeebeWorker(type = "shipOrder", autoComplete = true)
public ProcessVariables shipOrder(@ZeebeTypedVariables ProcessVariables variables){
  // do whatever you need to do
  return variables;
}

How do we know that the returned object must be mapped back to variables?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Feature Requests: What are they and how to manage them
Feature requests are a form of product feedback you may frequently encounter as a SaaS product manager. They typically come in the form...
Read more >
Feature request handling - Zendesk help
1. Create an Enhancement request ticket in Jira assigned to Development · 2. Evaluate the request and decide on delivery vehicle and release ......
Read more >
How To Handle Feature Requests - The Ultimate Guide for ...
How to track and manage feature requests in an organized and systematic way, all leading to better product execution.
Read more >
Handle Requests Sent by Alexa | Alexa Skills Kit
This handler uses functions provided with the RequestEnvelopeUtils to retrieve a slot value. You can also access slots via the intent object within...
Read more >
In-App Feature Requests - Instabug
To be able to use Instabug's Feature Requests product, you must first integrate the SDK. Allowing users to suggest new features can be...
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