Framework for building distributed services