Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs about nesting ServiceLaunchers #14

Closed
weissi opened this issue Apr 2, 2020 · 5 comments · Fixed by #34
Closed

docs about nesting ServiceLaunchers #14

weissi opened this issue Apr 2, 2020 · 5 comments · Fixed by #34
Labels
area/documentation Improvements or additions to documentation.
Milestone

Comments

@weissi
Copy link
Collaborator

weissi commented Apr 2, 2020

Very clearly ServiceLaucher is helpful for the top-level thing in probably main.swift and that's why it has builtin support for handling signals & doing backtraces.

However, the lifecycle concept is much bigger than what you do in main.swift.

Consider the following example:

final class MySystem {
    private let subSys1
    private let subSys2
    private let lifecycle
    init() {
        self.subSys1 = SubSys1()
        self.sybSys2 = SubSys2()
        self.lifecycle.register(name: "sub sys 1", start: self.subSys1.start, shutdown: self.subSys1.shutdown)
        self.lifecycle.register(name: "sub sys 2", start: self.subSys2.start, shutdown: self.subSys2.shutdown)
    }
    func start() {
        self.lifecycle.start() // calls subSys1.start and subSys2.start
    }
    func shutdown() {
        self.lifecycle.shutdown()
    }
}

There, lifecycle is also super useful and I think we should add an example like this to the docs. And the API docs need a big fat warning that catching signals & registering backtraces is only for the top-level ServiceLauncher.

@weissi weissi added the area/documentation Improvements or additions to documentation. label Apr 2, 2020
@tomerd
Copy link
Contributor

tomerd commented Apr 2, 2020

@weissi this is a great idea, we can def make them compose nicely. to your point on top-level we can potentially compose the type hierarchy differently to make this easier and safer

@weissi
Copy link
Collaborator Author

weissi commented Apr 3, 2020

@tomerd ah you mean a different type for top-level and not? I think I like that. So one would be called ServiceLauncher and one ComponentLifecycle or so?

@tomerd tomerd mentioned this issue Apr 3, 2020
@tomerd tomerd linked a pull request Apr 3, 2020 that will close this issue
@tomerd
Copy link
Contributor

tomerd commented Apr 7, 2020

@tomerd ah you mean a different type for top-level and not? I think I like that. So one would be called ServiceLauncher and one ComponentLifecycle or so?

exactly, see #15 for a POC

@tomerd tomerd added this to the 1.0.0 milestone Apr 7, 2020
@ktoso
Copy link
Contributor

ktoso commented Apr 8, 2020

Yeah I quite like the direction :)

@tomerd tomerd linked a pull request Apr 9, 2020 that will close this issue
@tomerd tomerd modified the milestones: 1.0.0, 1.0.0-alpha.2 Apr 10, 2020
@tomerd
Copy link
Contributor

tomerd commented Apr 10, 2020

closed via #34

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/documentation Improvements or additions to documentation.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants