You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by GitBox <gi...@apache.org> on 2018/12/06 23:25:21 UTC

[GitHub] lburgazzoli opened a new issue #268: Refactor traits lifecycle

lburgazzoli opened a new issue #268: Refactor traits lifecycle
URL: https://github.com/apache/camel-k/issues/268
 
 
   The current trait life-cycle is something like:
   
   * check if it can be applied to the current environment
   * check if it should auto-configure
      * auto-configure it
   * check if it is enabled
      * execute it
   
   I think that we can condense the first three steps in a single one who is responsible to set up the trait according to the given environment and user parameters, validate the set-up and finally determine if the trait should be executed or not.
   
   The `Trait` interface then would look like:
   
   ```go
   type Trait interface {
       Identifiable
   
       Configure() (bool, err)
       Apply(environment *Environment) error
   }
   ```
   
   The _trait loop_ then would look like:
   
   ```go
   for _, trait := range traits {
       enabled, err := trait.Configure(env)
       if err != nil {
           return err
       }
   
       if enabled {
           if err := trait.Apply(env); err != nil {
   	    return err
   	}
   
           env.ExecutedTraits = append(env.ExecutedTraits, trait.ID())
       }
   }
   ```
   
   @nicolaferraro make sense ?
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services