expvarmon icon indicating copy to clipboard operation
expvarmon copied to clipboard

Moves the main.go into cmd/expvarmon folder to make it go gettable to…

Open arsham opened this issue 9 years ago • 2 comments

Moves the main.go into cmd/expvarmon. This way people can install different versions of executables and use expvarmon as a library. It also fixed undefined DefaultEndpoint when I tried to run the main. Also I would create another cmd/expvardummon (or any other names you like) to separate the dummy prints with the normal ones.

Please note that I passed the interval to constructors for the following reasons:

  • It is a configuration value
  • Once it is set, it is not supposed to be changed, hence unexported variable.

arsham avatar Dec 08 '16 10:12 arsham

Hey @arsham. Thanks, I will review it in details next week, but can you please elaborate on the reasons of moving to cmd/ folder? I'm totally aware of this practice, but so far expvarmon is not supposed to be used as a library. Can you show any examples how it can be useful? And also I didn't quite get how it can help to install different versions of executables. Thanks in advance.

divan avatar Dec 08 '16 11:12 divan

No problem.

Well, you spoiled the surprise mate! I am planninng to add a few Writers to the mix and have this library to be used for streaming the data to ElasticSearch/influxdb. I'm sure people will come up with other nice usages if this was a library.

On the other hand (the other question), you could have another binary called expvarmon-es and bootstrap it with additional elasticsearch location setting. If you do that with your current setup, the main function will get poluted by many if statements.

In my opinion (I might be wrong), a main.go file should be used for reading the input and bootstrap an application, nothing more. @ardan-bkennedy I would appreciate your input on this.

We can further this conversation if more clarification is needed.

Cheers, Arsham

arsham avatar Dec 08 '16 12:12 arsham