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

Refactor CLI packages #195

Merged
merged 13 commits into from
Dec 15, 2017
Merged

Refactor CLI packages #195

merged 13 commits into from
Dec 15, 2017

Conversation

masomel
Copy link
Member

@masomel masomel commented Nov 13, 2017

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.

  • refactor encoding
  • refactor common server functionality
  • refactor server listener
  • move logger from utils to application
  • refactor bot
  • refactor common CLI cmds
  • refactor configs
  • refactor CLI tools

@liamsi
Copy link
Member

liamsi commented Nov 13, 2017

Closing and reopening to trigger travis ...

@liamsi liamsi closed this Nov 13, 2017
@liamsi liamsi reopened this Nov 13, 2017
@masomel masomel force-pushed the refactor-cli branch 3 times, most recently from 559e558 to c9ad99b Compare November 19, 2017 08:19
@masomel masomel added this to the 0.1.2 milestone Dec 1, 2017
@masomel masomel requested a review from vqhuy December 2, 2017 16:30
@vqhuy vqhuy changed the title [WIP] Refactor CLI pckages [WIP] Refactor CLI packages Dec 2, 2017
// any kind of CONIKS application-level executable (e.g. key server,
// client etc.).
type AppConfig interface {
InitConfig(file string) error
Copy link
Member

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.

Copy link
Member Author

@masomel masomel Dec 2, 2017

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.

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 {
Copy link
Member

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)

@masomel masomel changed the title [WIP] Refactor CLI packages Refactor CLI packages Dec 4, 2017
@masomel
Copy link
Member Author

masomel commented Dec 4, 2017

@c633 When you get a chance, can you please review?

@masomel masomel requested review from arlolra and liamsi December 4, 2017 08:11
// permissions.
func (server *ConiksServer) Run(addrs []*Address) {
server.WaitStopAdd()
go server.EpochUpdate()
Copy link
Member

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.

Copy link
Member Author

@masomel masomel Dec 4, 2017

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.

Copy link
Member Author

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?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calling for help @liamsi @arlolra ...

@vqhuy
Copy link
Member

vqhuy commented Dec 4, 2017

I love what you did with cli packages. I have only a concern regarding the ServerBase exported APIs.

Copy link
Member

@vqhuy vqhuy left a 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.

@masomel masomel merged commit 234bb6f into master Dec 15, 2017
@vqhuy vqhuy deleted the refactor-cli branch December 15, 2017 23:27
masomel added a commit that referenced this pull request Dec 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants