From e191c3185aadb4e0b5f2d8cc0f07e465ac4fb85f Mon Sep 17 00:00:00 2001 From: Diptanu Choudhury Date: Mon, 11 Jul 2016 12:23:10 -0600 Subject: [PATCH] Added a method for listing jobs whose id matches a prefix --- nomad/state/state_store.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/nomad/state/state_store.go b/nomad/state/state_store.go index b14a96bd1..2d60d7410 100644 --- a/nomad/state/state_store.go +++ b/nomad/state/state_store.go @@ -492,6 +492,18 @@ func (s *StateStore) JobSummaries() (memdb.ResultIterator, error) { return iter, nil } +// JobSummaryByPrefix is used to look up Job Summary by id prefix +func (s *StateStore) JobSummaryByPrefix(id string) (memdb.ResultIterator, error) { + txn := s.db.Txn(false) + + iter, err := txn.Get("jobsummary", "id_prefix", id) + if err != nil { + return nil, fmt.Errorf("eval lookup failed: %v", err) + } + + return iter, nil +} + // UpsertPeriodicLaunch is used to register a launch or update it. func (s *StateStore) UpsertPeriodicLaunch(index uint64, launch *structs.PeriodicLaunch) error { txn := s.db.Txn(true)