-
Notifications
You must be signed in to change notification settings - Fork 30
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
Refactor CLI packages #195
Conversation
Closing and reopening to trigger travis ... |
a56f056
to
77e9549
Compare
559e558
to
c9ad99b
Compare
c9ad99b
to
08786f0
Compare
application/config.go
Outdated
// any kind of CONIKS application-level executable (e.g. key server, | ||
// client etc.). | ||
type AppConfig interface { | ||
InitConfig(file string) error |
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.
Could be just Init
, or Load
. I think the latter is more precise.
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.
Hmm, I thought of this. There already is a Load
function in application/config
, so I didn't want to have double-naming to reduce confusion.
application/bots/twitterbot.go
Outdated
if _, err := toml.DecodeFile(path, &conf); err != nil { | ||
return nil, fmt.Errorf("Failed to load config: %v", err) | ||
var conf *TwitterConfig = &TwitterConfig{} | ||
if err := conf.InitConfig(path); 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.
Please see https://github.com/coniks-sys/coniks-go/pull/195/files#r154509882. Then this could be
var config *TwitterConfig = &TwitterConfig{}
config.Load(path)
@c633 When you get a chance, can you please review? |
// permissions. | ||
func (server *ConiksServer) Run(addrs []*Address) { | ||
server.WaitStopAdd() | ||
go server.EpochUpdate() |
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 do
server.WaitStopAdd()
go func() {
server.EpochUpdate()
server.WaitStopDone()
}
It looks more idiomatic Go.
That being said, I would love to find another way to refactor these APIs.
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 agree, I'm not 100% happy with these APIs. I would be happier if we didn't have to expose the WaitGroup
to the server/auditor at all. If you have an alternative suggestion, please let me know! We might find a better way to express this API when implementing the auditor.
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.
According to places like https://tour.golang.org/concurrency/1, go server.EpochUpdate()
is just as idiomatic in Go. Is there a reason why these goroutines should be in anonymous functions?
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 love what you did with |
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.
Please leave a TODO for the ServerBase API, so we don't forget about it.
Addresses #194
This PR moves the cli binaries to
/cli
and refactors some common functionality used to implement various CONIKS executables or client applications in the/application
package.