RussellLuo / timingwheel

Golang implementation of Hierarchical Timing Wheels.
MIT License
656 stars 121 forks source link

add example for timingwheel #2

Closed tsingson closed 5 years ago

tsingson commented 5 years ago

add example

RussellLuo commented 5 years ago

@tsingson Thanks for your contribution! The example code you provide is correct and well-formatted, but I think it's a little complicated.

While using the same library (here is timingwheel), different users have different use-cases and different opinions about how to structure their code. For simplicity, I think the examples of timingwheel should try to avoid:

In other words, being a basic library, timingwheel should provide examples as concentrated (also simple) as possible, just like what most standard Go libraries do.

So if I understand your example code correctly, the core snippet that is concentrated on how to use timingwheel is mostly the same with the first example (i.e. Example (AddTimer)) provided in Godoc?

RussellLuo commented 5 years ago

The API to create a new timer has been changed (by this commit), see Godoc for new examples.

I hope the new API will be considered more user-friendly.

tsingson commented 5 years ago

Thank you for your quick response.

Yes, my example is a bit complicated and not easy to understand. Perhaps this is related to personal coding habits.