sholsapp / gallocy

A distributed shared memory infrastructure.
27 stars 9 forks source link

Stop using global variables for consensus module. #34

Open sholsapp opened 8 years ago

sholsapp commented 8 years ago

Using global variables make testing hard, especially for the consensus module.

This becomes more apparent when you think about how to test GallocyState, GallocyServer, GallocyClient, and GallocyConfig together. Today, all of these major entities are global variables that are defined in entrypoint.h. Everything accesses these entities through these global handles, which makes unit testing hard.

This will require rethinking a few abstractions, since everything accesses these entities through the global handles. E.g., we'll need to rethink how we do HTTP callbacks in the consensus module because they depend on the ability to "change the state of the machine" based on HTTP responses, whereas the HTTP client only allows for a generic callback. This type of pattern is used in a few places, and each one will require a rethink.