Merge pull request '[agent/codex:gpt-5.4-mini] Read ~/spec/code/core/go/store/RFC.md fully. Find features d...' (#46) from agent/read---spec-code-core-go-store-rfc-md-fu into dev
This commit is contained in:
commit
4d2d4e5220
3 changed files with 22 additions and 7 deletions
|
|
@ -97,10 +97,10 @@ func main() {
|
|||
return
|
||||
}
|
||||
|
||||
watcher := storeInstance.Watch("group", "*")
|
||||
defer storeInstance.Unwatch(watcher)
|
||||
events := storeInstance.Watch("group")
|
||||
defer storeInstance.Unwatch("group", events)
|
||||
go func() {
|
||||
for event := range watcher.Events {
|
||||
for event := range events {
|
||||
fmt.Println(event.Type, event.Group, event.Key, event.Value)
|
||||
}
|
||||
}()
|
||||
|
|
|
|||
18
journal.go
18
journal.go
|
|
@ -25,8 +25,11 @@ const createJournalEntriesTableSQL = `CREATE TABLE IF NOT EXISTS journal_entries
|
|||
)`
|
||||
|
||||
var (
|
||||
journalBucketPattern = regexp.MustCompile(`bucket:\s*"([^"]+)"`)
|
||||
journalMeasurementPattern = regexp.MustCompile(`(?:_measurement|measurement)\s*==\s*"([^"]+)"`)
|
||||
journalBucketPattern = regexp.MustCompile(`bucket:\s*"([^"]+)"`)
|
||||
journalMeasurementPatterns = []*regexp.Regexp{
|
||||
regexp.MustCompile(`(?:_measurement|measurement)\s*==\s*"([^"]+)"`),
|
||||
regexp.MustCompile(`\[\s*"(?:_measurement|measurement)"\s*\]\s*==\s*"([^"]+)"`),
|
||||
}
|
||||
)
|
||||
|
||||
type journalExecutor interface {
|
||||
|
|
@ -132,7 +135,7 @@ func (storeInstance *Store) queryJournalFlux(flux string) (string, []any, error)
|
|||
builder.WriteString(" AND bucket_name = ?")
|
||||
arguments = append(arguments, bucket)
|
||||
}
|
||||
if measurement := quotedSubmatch(journalMeasurementPattern, flux); measurement != "" {
|
||||
if measurement := firstQuotedSubmatch(journalMeasurementPatterns, flux); measurement != "" {
|
||||
builder.WriteString(" AND measurement = ?")
|
||||
arguments = append(arguments, measurement)
|
||||
}
|
||||
|
|
@ -303,6 +306,15 @@ func quotedSubmatch(pattern *regexp.Regexp, value string) string {
|
|||
return match[1]
|
||||
}
|
||||
|
||||
func firstQuotedSubmatch(patterns []*regexp.Regexp, value string) string {
|
||||
for _, pattern := range patterns {
|
||||
if match := quotedSubmatch(pattern, value); match != "" {
|
||||
return match
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func regexpSubmatch(pattern *regexp.Regexp, value string, index int) string {
|
||||
match := pattern.FindStringSubmatch(value)
|
||||
if len(match) <= index {
|
||||
|
|
|
|||
5
store.go
5
store.go
|
|
@ -113,7 +113,10 @@ func New(databasePath string, options ...StoreOption) (*Store, error) {
|
|||
}
|
||||
}
|
||||
storeInstance.startBackgroundPurge(purgeContext)
|
||||
storeInstance.cleanUpOrphanedWorkspaces(defaultWorkspaceStateDirectory)
|
||||
orphanWorkspaces := storeInstance.RecoverOrphans(defaultWorkspaceStateDirectory)
|
||||
for _, orphanWorkspace := range orphanWorkspaces {
|
||||
orphanWorkspace.Discard()
|
||||
}
|
||||
return storeInstance, nil
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue