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

Where to set the functional options API for sbot? #84

Closed
mycognosist opened this issue Mar 15, 2021 · 3 comments
Closed

Where to set the functional options API for sbot? #84

mycognosist opened this issue Mar 15, 2021 · 3 comments

Comments

@mycognosist
Copy link
Member

Thanks to your great docs over at dev.scuttlebutt.nz, I know that it's possible to alter the functionality of the sbot server using the options API (for example, in order to define a custom database mountpoint). However, I'm not sure how to do this in practice.

Based on the test code in ssb/cmd/sbotcli/simple_test.go, my current assumption is that the options need to be defined in ssb/cmd/sbotcli/main.go prior to compilation. Is that correct? I'd be grateful for a short explanation of how to achieve this (for example, where would I inject those definitions? In func initClient() or elsewhere?).

Thanks in advance ☺️

@cryptix
Copy link
Member

cryptix commented Mar 15, 2021

Hmm... Interesting! :)

Could you give a bit more context on what you are trying to do? The list of all the available options is best looked at on this godoc page for the sbot package.

The example you linked to is basically a slimmed down version of cmd/go-sbot/main.go which is basically just a thin wrapper which unpacks CLI flags and passes them on to the options API.

If go-sbot doesn't have the option you are looking for (I vaguely believe it does have all of them but would like to fix that if it doesn't) the code to create a peer inside another go program is exactly like that in the example. You just add the options (with the package name first) as one more argument to sbot.Sbot(...). They are variadic, so the number doesn't matter.

HTH?

@cryptix
Copy link
Member

cryptix commented Mar 15, 2021

ah.. ps: cmd/sbotcli is just a ssb-client. The server/bot magic is in ssb/sbot which has an options.go, etc. but you don't need to mess with any of that unless you want new options that aren't there yet.

@mycognosist
Copy link
Member Author

@cryptix

Thanks for the extra details! I think I understand now.

My question was basically: how to select the different options? Now I see that they're exposed by go-sbot via flags. So I can set hops to 2, for example: go-sbot -hops 2. Or I could set a custom mountpoint: go-sbot -repo "/some/other/dir". Cool. Thanks again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants