Repository navigation
services: key services by server id; auto start cli service flags - #6425
Merged
Merged
Conversation
Before this, services provided as CLI flag values were not automatically started, so user module code needed to explicitly start them (or implicitly start them via a service binding), which is somewhat surprising and boilerplatey since there's not really any cases where a user wouldn't want the host service to already be running. This is debatable though. Now, the CLI calls start on host services provided as flag args. In order for this to work, there was also a change needed in the internal services implementation to key services by the ServerID rather than ClientID. The difference is that now the state of a service is shared across a whole session, which includes the CLI and all modules it invokes (directly or transitively). Otherwise even if the CLI auto starts the service it will still not be running when the module code uses it. That change is also fairly debatable, not a very clear cut best answer here. Previously, every module could start an identical service and get their own instance of it. But now modules in a session starting an identical service will get a shared instance of it. Both behaviors are logical and possibly desired in different use cases. I think the main argument for changing to key by ServerID is that it makes it possible for services to be shared across a session, but still leaves open the possibilty for them to not be shared by having users include some "module-specific" key in the service's definition that causes it to not be de-duped. This is as opposed to the previous use of ClientID that made it impossible for services to be shared. One other possible solution here would be to only key host services (i.e. the one started by the CLI here) by the server ID, but use ClientID and retain the previous behavior for other services. That feels a bit too complicated (both to explain and to implement) to be worth it, but is probably possible if it ends up making more sense. Signed-off-by: Erik Sipsma <[email protected]>
vito
approved these changes
Jan 15, 2024
vito
left a comment
Contributor
There was a problem hiding this comment.
The ClientID -> ServerID change sounds good to me given your reasoning. 👍
Signed-off-by: Erik Sipsma <[email protected]>
zeroware
pushed a commit
to zeroware/dagger
that referenced
this pull request
Jan 18, 2024
…gger#6425) * services: key services by server id; auto start cli service flags Before this, services provided as CLI flag values were not automatically started, so user module code needed to explicitly start them (or implicitly start them via a service binding), which is somewhat surprising and boilerplatey since there's not really any cases where a user wouldn't want the host service to already be running. This is debatable though. Now, the CLI calls start on host services provided as flag args. In order for this to work, there was also a change needed in the internal services implementation to key services by the ServerID rather than ClientID. The difference is that now the state of a service is shared across a whole session, which includes the CLI and all modules it invokes (directly or transitively). Otherwise even if the CLI auto starts the service it will still not be running when the module code uses it. That change is also fairly debatable, not a very clear cut best answer here. Previously, every module could start an identical service and get their own instance of it. But now modules in a session starting an identical service will get a shared instance of it. Both behaviors are logical and possibly desired in different use cases. I think the main argument for changing to key by ServerID is that it makes it possible for services to be shared across a session, but still leaves open the possibilty for them to not be shared by having users include some "module-specific" key in the service's definition that causes it to not be de-duped. This is as opposed to the previous use of ClientID that made it impossible for services to be shared. One other possible solution here would be to only key host services (i.e. the one started by the CLI here) by the server ID, but use ClientID and retain the previous behavior for other services. That feels a bit too complicated (both to explain and to implement) to be worth it, but is probably possible if it ends up making more sense. Signed-off-by: Erik Sipsma <[email protected]> * update service unit test to account for client->server id Signed-off-by: Erik Sipsma <[email protected]> --------- Signed-off-by: Erik Sipsma <[email protected]>
This was referenced Jan 29, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Before this, services provided as CLI flag values were not automatically started, so user module code needed to explicitly start them (or implicitly start them via a service binding), which is somewhat surprising and boilerplatey since there's not really any cases where a user wouldn't want the host service to already be running. This is debatable though.
Now, the CLI calls start on host services provided as flag args.
In order for this to work, there was also a change needed in the internal services implementation to key services by the ServerID rather than ClientID. The difference is that now the state of a service is shared across a whole session, which includes the CLI and all modules it invokes (directly or transitively). Otherwise even if the CLI auto starts the service it will still not be running when the module code uses it.
That change is also fairly debatable, not a very clear cut best answer here. Previously, every module could start an identical service and get their own instance of it. But now modules in a session starting an identical service will get a shared instance of it. Both behaviors are logical and possibly desired in different use cases.
I think the main argument for changing to key by ServerID is that it makes it possible for services to be shared across a session, but still leaves open the possibilty for them to not be shared by having users include some "module-specific" key in the service's definition that causes it to not be de-duped. This is as opposed to the previous use of ClientID that made it impossible for services to be shared.
One other possible solution here would be to only key host services (i.e. the one started by the CLI here) by the server ID, but use ClientID and retain the previous behavior for other services. That feels a bit too complicated (both to explain and to implement) to be worth it, but is probably possible if it ends up making more sense.