docs: def on_capacity(self, connection, command, query_kwargs, response,
                      capacity):
          """ Hook that runs in response to a 'returned capacity' event """
          now = time.time()
          args = (connection, command, query_kwargs, response, capacity)
          # Check total against the total_cap
          self._wait(args, now, self.total_cap, self._total_consumed,
                     capacity.total)
  
          # Increment table consumed capacity & check it
          if capacity.tablename in self.table_caps:
              table_cap = self.table_caps[capacity.tablename]
          else:
              table_cap = self.default_cap
          consumed_history = self.get_consumed(capacity.tablename)
          if capacity.table_capacity is not None:
              self._wait(args, now, table_cap, consumed_history,
                         capacity.table_capacity)
          # The local index consumed capacity also counts against the table
          if capacity.local_index_capacity is not None:
              for consumed in six.itervalues(capacity.local_index_capacity):
                  self._wait(args, now, table_cap, consumed_history, consumed)
  
          # Increment global indexes
          # check global indexes against the table+index cap or default
          gic = capacity.global_index_capacity
          if gic is not None:
              for index_name, consumed in six.iteritems(gic):
                  full_name = capacity.tablename + ':' + index_name
                  if index_name in table_cap:
                      index_cap = table_cap[index_name]
                  elif full_name in self.table_caps:
                      index_cap = self.table_caps[full_name]
                  else:
                      # If there's no specified capacity for the index,
                      # use the cap on the table
                      index_cap = table_cap
                  consumed_history = self.get_consumed(full_name)
                  self._wait(args, now, index_cap, consumed_history, consumed)