-
Notifications
You must be signed in to change notification settings - Fork 36
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
Initial config spec #93
Conversation
specs/CONFIG.md
Outdated
* Array[Maddr String] | ||
* `[]` | ||
* `DHT` | ||
* `Enabled` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rather call this Server
and Client
instead of ClientMode
and Enabled
. ClientMode also enabls the dht.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unless there is an implication that we need to set both Enabled
and ClientMode
to get the dht client behaviour.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At least in the Go implementation, the don't seem to depend on each other. Preferably it would be one value that would be chosen from an Enum, though, unless it is possible to have both enabled at the same time?
{ | ||
"ListenAddr": "/unix/tmp/p2pd.sock", | ||
"Quiet": false, | ||
"ID": "", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should probably be missing altogether instead of being empty.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In terms of real JSON, that is true. But for this "default config" example, do you think we should strike empty labels?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe rather than having this be a "default" example have it be a "complete" example with all of the fields filled in. as a developer, i find those a lot more helpful, because it lets me know what options are possible at a glance! obv the schema does this, but i think that's useful. we could include the "default" config below it, with empty options elided as suggested.
"ID": "", | ||
"Bootstrap": { | ||
"Enabled": false, | ||
"Peers": [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
semantically this looks odd when enabled (the empty Peers
list).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should probably be elided.
@jacobheun @vasco-santos @vyzo @bigs + anyone I missed Any thoughts on how this config should be maintained, and if it should be generated? I was thinking of generating the conf as a protobuf message, since that could be shared between language implementations. |
Why not just json? We don't gain anything by using protobuf. |
our thinking was to make it seamless for all language implementations to
have the same serialization
…On Sun, Mar 31, 2019 at 04:46 vyzo ***@***.***> wrote:
Why not just json? We don't gain anything by using protobuf.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#93 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AANBWupL2zfarkU0MC2XjJDWfQ6K3m0tks5vcHXcgaJpZM4cTZPR>
.
|
json already does that. |
JSON doesn't generate the structs we will use to hold the config in Go. There are some third party libs we could use to generate Go structs from JSON, but at that point why would we not use proto like we do everywhere else? If we don't want to generate, then anytime the JSON spec changes, we will also need to change all of the individual language implementations for daemons too. If we don't care about that, then I will get started on implementation that accepts standard JSON and marshals it into a Go defined struct. I thought I the discussion was worth having. |
I don't understand this. We will have to write the structs by hand anyway or write the protobuf for it. |
I agree that we should just use json. Having textual configuration makes it a lot easier for users to be able to view/edit/create configurations with a simple editor. Needing to leverage a generator or processor would feel irritating to me as a user trying to set up a new daemon, or to even just view the config for a running daemon. |
+1 on JSON config here |
totally down, but to be clear the idea was to use protobuf’s JSON serializer/deserializer. just use protobuf as source of truth for the structs. i agree it’s a bit overkill. |
What I’m understanding is that we wanted to use protobuf to define an interoperable schema. I think defining a schema is a great idea. How about we write a JSON Schema file for that, and make it part of the specs? |
@raulk perfect! |
specs/CONFIG.md
Outdated
* List of bootstrap peers; defaults to the IPFS DHT peers | ||
* Array[Maddr String] | ||
* `[]` | ||
* `DHT` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed earlier, we should be able to have more control on the DHT configuration.
For example, we have the interop tests for the DHT content fetching blocked by not being able to add custom validators or selectors. Moreover, I think we should be able to add other options to the DHT, such as the random walk config libp2p/js-libp2p-kad-dht/src/index.js#L39-L42 and the constants libp2p/js-libp2p-kad-dhtmaster/src/constants.js#L32-L39. The constants being configurable is a topic that was already discussed a few times in the context of experiments with the testbed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That sounds good, but it also sounds like it's out of scope of this particular ticket. This config should be for the daemon as it currently stands. Any feature additions to the deamon will also need to include appropriate config edits
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perhaps it should be its own sub object. its absence represents it being disabled. even if it only has one or two options to start. thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All right, that sounds correct for me! Just mentioned to not fall out of the radar!
It is also important to consider that as we are creating the config now, I think we should at least prepare the dht options to get the remaining configs. Otherwise, if we will expect a string for now, we will create a breaking change afterward.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I edited the DHT property to be an object, and added a field Mode
that is an enum of "client", "full" and empty string. It defaults to empty string. It should be easier to add extra fields now.
Can you rebase? There are two new options for the |
@vyzo rebased and included those new options |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will give a more thorough review in the am but this is looking very good
specs/CONFIG.md
Outdated
* List of bootstrap peers; defaults to the IPFS DHT peers | ||
* Array[Maddr String] | ||
* `[]` | ||
* `DHT` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perhaps it should be its own sub object. its absence represents it being disabled. even if it only has one or two options to start. thoughts?
config/config.go
Outdated
return nil | ||
} | ||
|
||
type bootstrap struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
feels like these should be public, but i'm open to suggestion!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
second that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason as to why? My thought was that they were only being used internally for marshaling
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Command line options should not be ignored when there is a config, but rather override options.
config/config.go
Outdated
return err | ||
} | ||
jma := JSONMaddr{ma} | ||
jm = &jma |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just jm = &JSONMaddr(ma}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
config/config.go
Outdated
return nil | ||
} | ||
|
||
type bootstrap struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
second that.
if err := json.Unmarshal(body, c); err != nil { | ||
log.Fatal(err) | ||
} | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need to allow command line options to override the config.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think we could make that in another change, so long as we note the behavior in the readme. maybe we just make an issue for that to support config merging. this would be a big help in the meantime
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should do it here, it's a pretty simple thing to do. It would be very surprising to pass options that are ignored when also passing a config.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sounds good let’s do overrides
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great work, thanks for taking this on. just a few changes requested
p2pd/main.go
Outdated
if err != nil { | ||
log.Fatal(err) | ||
} | ||
if err := json.Unmarshal(body, c); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think this (and the instance below) should be &c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah right
if err := json.Unmarshal(body, c); err != nil { | ||
log.Fatal(err) | ||
} | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think we could make that in another change, so long as we note the behavior in the readme. maybe we just make an issue for that to support config merging. this would be a big help in the meantime
{ | ||
"ListenAddr": "/unix/tmp/p2pd.sock", | ||
"Quiet": false, | ||
"ID": "", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe rather than having this be a "default" example have it be a "complete" example with all of the fields filled in. as a developer, i find those a lot more helpful, because it lets me know what options are possible at a glance! obv the schema does this, but i think that's useful. we could include the "default" config below it, with empty options elided as suggested.
Is it possible to make flags order dependent in Go? Perhaps we give preference to whatever is provided last
… On Apr 18, 2019, at 22:05, vyzo ***@***.***> wrote:
@vyzo commented on this pull request.
In p2pd/main.go:
> if err != nil {
log.Fatal(err)
}
+ if err := json.Unmarshal(body, c); err != nil {
+ log.Fatal(err)
+ }
+ } else {
I think we should do it here, it's a pretty simple thing to do. It would be very surprising to pass options that are ignored when also passing a config.
—
You are receiving this because you were assigned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
not that I know of. |
@bigs relay, pubsub, connectionManager and bootstrap all have |
@mvid i like the explicit nature, let's keep it. let's do the command line overrides and merge this |
@bigs ok, it now overrides with flags |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks great
Created to address #63