func (b *activeRequestsKeyspace) Fetch(keys []string) ([]datastore.AnnotatedPair, []errors.Error) { var errs []errors.Error rv := make([]datastore.AnnotatedPair, 0, len(keys)) server.ActiveRequestsForEach(func(id string, request server.Request) { item := value.NewAnnotatedValue(map[string]interface{}{ "RequestId": id, "RequestTime": request.RequestTime().String(), "ElapsedTime": time.Since(request.RequestTime()).String(), "ExecutionTime": time.Since(request.ServiceTime()).String(), "State": request.State(), }) if request.Statement() != "" { item.SetField("Statement", request.Statement()) } if request.Prepared() != nil { p := request.Prepared() item.SetField("Prepared.Name", p.Name()) item.SetField("Prepared.Text", p.Text()) } item.SetAttachment("meta", map[string]interface{}{ "id": id, }) rv = append(rv, datastore.AnnotatedPair{ Key: id, Value: item, }) }) return rv, errs }
func (pi *activeRequestsIndex) ScanEntries(requestId string, limit int64, cons datastore.ScanConsistency, vector timestamp.Vector, conn *datastore.IndexConnection) { defer close(conn.EntryChannel()) numRequests, err := server.ActiveRequestsCount() if err != nil { conn.Error(err) return } requestIds := make([]string, numRequests) server.ActiveRequestsForEach(func(id string, request server.Request) { requestIds = append(requestIds, id) }) for _, name := range requestIds { entry := datastore.IndexEntry{PrimaryKey: name} conn.EntryChannel() <- &entry } }