Skip to content

Update Spring Boot DaprBeanPostProcessor to evaluate expressions Topic attribute values #554

Description

@rovangju

Assuming a spring app with an application.properties file containing

pubsubProp=banana

Current behavior (kotlin for example)

@Topic(name = "/api/banana", pubsubName = "\${pubsubProp}") //  pubsubName treated as literal string: \${pubsubProp}
@PostMapping("/api/banana")
suspend fun doItAgain(ce: CloudEvent) {
    // stuff
}

Proposed behavior (kotlin for example)

@Topic(name = "/api/banana", pubsubName = "\${pubsubProp}") // resolves to "banana" 
@PostMapping("/api/banana")
suspend fun doItAgain(ce: CloudEvent) {
    // stuff
}

Proposed method

This could be achieved by modifying the DaprBeanPostProcessor class to evaluate the attribute value with an EmbeddedValueResolver with the spring context.

This would also support other SPEL, e.g.: ${pubsubProp:defaultValue}, etc.

Activity

  1. artursouza commented on May 26, 2021

    @artursouza
    Contributor

    I am supportive of this change.

  2. added this to the v1.2 milestone on Jun 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions