- Timestamp:
- Nov 3, 2021, 5:21:05 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/downstream.go
r666 r667 1329 1329 ch := net.channels.Value(target) 1330 1330 1331 ctx, cancel := context.WithTimeout(context.TODO(), messageStoreTimeout) 1332 defer cancel() 1333 1331 1334 limit := 4000 1332 1335 targetCM := net.casemap(target) 1333 history, err := dc.user.msgStore.LoadLatestID( &net.Network, targetCM, msgID, limit)1336 history, err := dc.user.msgStore.LoadLatestID(ctx, &net.Network, targetCM, msgID, limit) 1334 1337 if err != nil { 1335 1338 dc.logger.Printf("failed to send backlog for %q: %v", target, err) … … 2335 2338 eventPlayback := dc.caps["draft/event-playback"] 2336 2339 2340 ctx, cancel := context.WithTimeout(context.TODO(), messageStoreTimeout) 2341 defer cancel() 2342 2337 2343 var history []*irc.Message 2338 2344 switch subcommand { 2339 2345 case "BEFORE": 2340 history, err = store.LoadBeforeTime( &network.Network, entity, bounds[0], time.Time{}, limit, eventPlayback)2346 history, err = store.LoadBeforeTime(ctx, &network.Network, entity, bounds[0], time.Time{}, limit, eventPlayback) 2341 2347 case "AFTER": 2342 history, err = store.LoadAfterTime( &network.Network, entity, bounds[0], time.Now(), limit, eventPlayback)2348 history, err = store.LoadAfterTime(ctx, &network.Network, entity, bounds[0], time.Now(), limit, eventPlayback) 2343 2349 case "BETWEEN": 2344 2350 if bounds[0].Before(bounds[1]) { 2345 history, err = store.LoadAfterTime( &network.Network, entity, bounds[0], bounds[1], limit, eventPlayback)2351 history, err = store.LoadAfterTime(ctx, &network.Network, entity, bounds[0], bounds[1], limit, eventPlayback) 2346 2352 } else { 2347 history, err = store.LoadBeforeTime( &network.Network, entity, bounds[0], bounds[1], limit, eventPlayback)2353 history, err = store.LoadBeforeTime(ctx, &network.Network, entity, bounds[0], bounds[1], limit, eventPlayback) 2348 2354 } 2349 2355 case "TARGETS": 2350 2356 // TODO: support TARGETS in multi-upstream mode 2351 targets, err := store.ListTargets( &network.Network, bounds[0], bounds[1], limit, eventPlayback)2357 targets, err := store.ListTargets(ctx, &network.Network, bounds[0], bounds[1], limit, eventPlayback) 2352 2358 if err != nil { 2353 2359 dc.logger.Printf("failed fetching targets for chathistory: %v", err) -
trunk/msgstore.go
r666 r667 3 3 import ( 4 4 "bytes" 5 "context" 5 6 "encoding/base64" 6 7 "fmt" … … 20 21 // LoadLatestID queries the latest non-event messages for the given network, 21 22 // entity and date, up to a count of limit messages, sorted from oldest to newest. 22 LoadLatestID( network *Network, entity, id string, limit int) ([]*irc.Message, error)23 LoadLatestID(ctx context.Context, network *Network, entity, id string, limit int) ([]*irc.Message, error) 23 24 Append(network *Network, entity string, msg *irc.Message) (id string, err error) 24 25 } … … 38 39 // both excluded. end may be before or after start. 39 40 // If events is false, only PRIVMSG/NOTICE messages are considered. 40 ListTargets( network *Network, start, end time.Time, limit int, events bool) ([]chatHistoryTarget, error)41 ListTargets(ctx context.Context, network *Network, start, end time.Time, limit int, events bool) ([]chatHistoryTarget, error) 41 42 // LoadBeforeTime loads up to limit messages before start down to end. The 42 43 // returned messages must be between and excluding the provided bounds. 43 44 // end is before start. 44 45 // If events is false, only PRIVMSG/NOTICE messages are considered. 45 LoadBeforeTime( network *Network, entity string, start, end time.Time, limit int, events bool) ([]*irc.Message, error)46 LoadBeforeTime(ctx context.Context, network *Network, entity string, start, end time.Time, limit int, events bool) ([]*irc.Message, error) 46 47 // LoadBeforeTime loads up to limit messages after start up to end. The 47 48 // returned messages must be between and excluding the provided bounds. 48 49 // end is after start. 49 50 // If events is false, only PRIVMSG/NOTICE messages are considered. 50 LoadAfterTime( network *Network, entity string, start, end time.Time, limit int, events bool) ([]*irc.Message, error)51 LoadAfterTime(ctx context.Context, network *Network, entity string, start, end time.Time, limit int, events bool) ([]*irc.Message, error) 51 52 } 52 53 -
trunk/msgstore_fs.go
r666 r667 3 3 import ( 4 4 "bufio" 5 "context" 5 6 "fmt" 6 7 "io" … … 477 478 } 478 479 479 func (ms *fsMessageStore) LoadBeforeTime( network *Network, entity string, start time.Time, end time.Time, limit int, events bool) ([]*irc.Message, error) {480 func (ms *fsMessageStore) LoadBeforeTime(ctx context.Context, network *Network, entity string, start time.Time, end time.Time, limit int, events bool) ([]*irc.Message, error) { 480 481 start = start.In(time.Local) 481 482 end = end.In(time.Local) … … 502 503 } 503 504 504 func (ms *fsMessageStore) LoadAfterTime( network *Network, entity string, start time.Time, end time.Time, limit int, events bool) ([]*irc.Message, error) {505 func (ms *fsMessageStore) LoadAfterTime(ctx context.Context, network *Network, entity string, start time.Time, end time.Time, limit int, events bool) ([]*irc.Message, error) { 505 506 start = start.In(time.Local) 506 507 end = end.In(time.Local) … … 526 527 } 527 528 528 func (ms *fsMessageStore) LoadLatestID( network *Network, entity, id string, limit int) ([]*irc.Message, error) {529 func (ms *fsMessageStore) LoadLatestID(ctx context.Context, network *Network, entity, id string, limit int) ([]*irc.Message, error) { 529 530 var afterTime time.Time 530 531 var afterOffset int64 … … 570 571 } 571 572 572 func (ms *fsMessageStore) ListTargets( network *Network, start, end time.Time, limit int, events bool) ([]chatHistoryTarget, error) {573 func (ms *fsMessageStore) ListTargets(ctx context.Context, network *Network, start, end time.Time, limit int, events bool) ([]chatHistoryTarget, error) { 573 574 start = start.In(time.Local) 574 575 end = end.In(time.Local) -
trunk/msgstore_memory.go
r666 r667 2 2 3 3 import ( 4 "context" 4 5 "fmt" 5 6 "time" … … 92 93 } 93 94 94 func (ms *memoryMessageStore) LoadLatestID( network *Network, entity, id string, limit int) ([]*irc.Message, error) {95 func (ms *memoryMessageStore) LoadLatestID(ctx context.Context, network *Network, entity, id string, limit int) ([]*irc.Message, error) { 95 96 _, _, seq, err := parseMemoryMsgID(id) 96 97 if err != nil { -
trunk/server.go
r662 r667 26 26 var upstreamMessageDelay = 2 * time.Second 27 27 var upstreamMessageBurst = 10 28 var messageStoreTimeout = 10 * time.Second 28 29 29 30 type Logger interface {
Note:
See TracChangeset
for help on using the changeset viewer.