You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brooklyn.apache.org by aledsage <gi...@git.apache.org> on 2017/03/09 00:01:15 UTC

[GitHub] brooklyn-server pull request #586: Conveniences for yaml

GitHub user aledsage opened a pull request:

    https://github.com/apache/brooklyn-server/pull/586

    Conveniences for yaml

    A few conveniences to make it easier to write my yaml blueprints! See individual commits for details.
    
    If anything in here looks controversial to you then please let me know, and I'll split things out into separate PRs.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/aledsage/brooklyn-server conveniences-for-yaml

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/brooklyn-server/pull/586.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #586
    
----
commit b2fd0e81761b30e963ffe12ae6108565d5f2ed1a
Author: Aled Sage <al...@gmail.com>
Date:   2017-03-08T20:37:41Z

    $brooklyn:object: support explicit \u201cdeferred\u201d
    
    YAML authors can specify \u201cdeferred\u201d, to force the object to only be
    constructed when the config is being retrieved.

commit 59624f52cbb2fc89cf5fcbba400a221db72c8028
Author: Aled Sage <al...@gmail.com>
Date:   2017-03-08T20:49:19Z

    TestHttpCall: support \u201cmaxAttempts\u201d config

commit acfcb91c311c177670629b54bd9d70a843e95611
Author: Aled Sage <al...@gmail.com>
Date:   2017-03-08T21:03:02Z

    Add typeCoercion (String->TimeZone; number->Date)

commit 7ddca12d489796bd916b1f8b70586b93dbdaabfa
Author: Aled Sage <al...@gmail.com>
Date:   2017-03-08T22:11:16Z

    $brooklyn:object - support coercing args

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] brooklyn-server issue #586: Conveniences for yaml

Posted by aledsage <gi...@git.apache.org>.
Github user aledsage commented on the issue:

    https://github.com/apache/brooklyn-server/pull/586
  
    @tbouron Thanks. My use-case for `deferred` is a bit unusual! The "general" use-case is where you want to delay the creation/evaluation of the object until it's actually needed. And to have it being called every time it is evaluated, rather than evaluated only once and its value stored. One might want this for a number of reasons:
    
    1. If evaluated statically, then that result is persisted (which may include confidential info). If `deferred`, then the persisted value will be the DSL.
    
    2. There is a difference in behaviour for if a `$brooklyn:object` has an arg that is deferred (e.g. an arg that is `$brooklyn:config(...)`) versus if all the args can be statically evaluated: with the former, the value is the "deferred DSL"; with the latter, it is evaluated immediately. This allows one to force the two ways to behave the same.
    
    My use-case is a bit sneaky (and one could argue misusing config, because the value changes each time you ask for it)! I am writing a yaml-based test for a service, and am using `org.apache.brooklyn.test.framework.TestHttpCall`. When constructing the URL, I need to include a timestamp (for "now") in the url query parameters. I therefore want some way to get the current timestamp at the time the url is being used (rather the time when the entity was constructed). For example:
    
    ```
          type: org.apache.brooklyn.test.framework.TestHttpCall
          brooklyn.config:
            url:
              $brooklyn:formatString:
              - "%s/usage/?startTime=2016-01-01T00:00:00Z&endTime=%s"
              - $brooklyn:component($brooklyn:config("targetId")).attributeWhenReady("main.uri")
              - $brooklyn:formatString:
                - "%sZ"
                - $brooklyn:object:
                    type: org.apache.brooklyn.util.time.Time
                    factoryMethod.name: makeDateString
                    factoryMethod.args:
                    - $brooklyn:object:
                        deferred: true
                        type: java.lang.System
                        factoryMethod.name: currentTimeMillis
                    - yyyy-MM-dd'T'HH:mm:ss
                    - UTC
    ```
    
    Without the `deferred: true`, the `endTime` is the time at which the entity was constructed. With the `deferred`, it is the time at which the entity's `start` effector is called (i.e. when it reads the `url` config value).


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] brooklyn-server issue #586: Conveniences for yaml

Posted by aledsage <gi...@git.apache.org>.
Github user aledsage commented on the issue:

    https://github.com/apache/brooklyn-server/pull/586
  
    Thanks @tbouron - merging now.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] brooklyn-server issue #586: Conveniences for yaml

Posted by tbouron <gi...@git.apache.org>.
Github user tbouron commented on the issue:

    https://github.com/apache/brooklyn-server/pull/586
  
    @aledsage That makes sense, the example helped a lot to understand.
    
    LGTM then


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] brooklyn-server pull request #586: Conveniences for yaml

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/brooklyn-server/pull/586


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] brooklyn-server issue #586: Conveniences for yaml

Posted by tbouron <gi...@git.apache.org>.
Github user tbouron commented on the issue:

    https://github.com/apache/brooklyn-server/pull/586
  
    Tested, LGTM.
    
    I'm just not understanding the use-case for the `deferred` in `$brooklyn:object`, could you give a bit more details on this @aledsage ?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---