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

Create flag for packages to detect which platform is being used. #106

Closed
2 tasks done
soapdog opened this issue May 27, 2021 · 2 comments · Fixed by #115
Closed
2 tasks done

Create flag for packages to detect which platform is being used. #106

soapdog opened this issue May 27, 2021 · 2 comments · Fixed by #115
Labels
enhancement New feature or request tier-2 secondary priority

Comments

@soapdog
Copy link
Owner

soapdog commented May 27, 2021

Soon there will be multiple platforms inside platforms/ each providing the same ssb.* high-level API with internals tweaked for specific SSB server implementations.

The plan is to have the following platforms:

Each package will declare which platforms it is compatible with, and won't be loaded when an incompatible platform is used.

The package declaration will include a new property supportedPlatforms which is an array of platform identifiers. Example:

supportedPlatforms: ["nodejs-ssb", "go-ssb"]

The running platform will be available at runtime as ssb.serverType so that code can branch.

  • implement supportedPlatforms package flag.
  • implement ssb.serverType runtime property.
@soapdog soapdog added enhancement New feature or request tier-2 secondary priority labels May 27, 2021
soapdog added a commit that referenced this issue Jul 14, 2021
refactoring platform from `ssb` to `nodejs-ssb` to prepare the ground for supporting `go-ssb` and `browsers-ssb` as well.

Related to: #104 #105 #106
soapdog added a commit that referenced this issue Jul 14, 2021
closes #106

This allows package developers to create branching code to support different SSB server types.
soapdog added a commit that referenced this issue Jul 14, 2021
Each package needs to declare which platforms they suppport. This value needs to match the running server type.

* `pkg.supportedPlatforms = ["nodejs-ssb"]`
* `ssb.serverType = "nodejs-ssb"

All packages patched to include this property.

closes #106
@soapdog
Copy link
Owner Author

soapdog commented Jul 14, 2021

This issue is done!

There is both ssb.serverType which is a String that should match the values in pkg.supportedPlatforms which is an Array of Strings. At the moment the only serverType is nodejs-ssb, but this is necessary groundwork to allow us to run other backends soon. It also enables package develolpers to branch their code depending on the server type and thus be able to support more than one server, example:

if (ssb.serverType === "nodejs-ssb") {
 // do something that is supported only on that server.
}

All packages have been patched to include a supportedPlatforms property.

@soapdog
Copy link
Owner Author

soapdog commented Aug 2, 2021

This flag has been changed from serverType to platform to be consistent with the supportedPlatforms property in the package declaration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request tier-2 secondary priority
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant