history_manager.go ×10

Frontier kind: Code frontier

unlabeled · c_19d279f01e6b

7 tests · 3452 LOC · 158 files · introduces 0 tests · 100 LOC · 2 files

Introduces — evidence that enters the hierarchy at this concept

Code
12 ranges100 lines · 2 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
542 ranges3452 lines · 158 files · Browse complete extent
All tests (intent)
7 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

2 files ranked by introduced lines: 100 introduced LOC across 12 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

go.temporal.io/server/common/persistence/tests/history_store.go 55 introduced LOC · 2 ranges

Open complete file

552 }
553
554 > func (s *HistoryEventsSuite) TestAppendBatches() { history_store.go
555 > treeID := uuid.NewString()
556 > branchID := uuid.NewString()
557 > branchToken, err := s.store.GetHistoryBranchUtil().NewHistoryBranch(
558 > uuid.NewString(),
559 > uuid.NewString(),
560 > uuid.NewString(),
561 > treeID,
562 > &branchID,
563 > []*persistencespb.HistoryBranchRange{},
564 > time.Duration(0),
565 > time.Duration(0),
566 > time.Duration(0),
567 > )
568 > s.NoError(err)
569 >
570 > eventsPacket1 := s.newHistoryEvents(
571 > []int64{1, 2, 3},
572 > rand.Int63(),
573 > 0,
574 > )
575 > eventsPacket2 := s.newHistoryEvents(
576 > []int64{4, 5},
577 > eventsPacket1.transactionID+100,
578 > eventsPacket1.transactionID,
579 > )
580 > eventsPacket3 := s.newHistoryEvents(
581 > []int64{6},
582 > eventsPacket2.transactionID+100,
583 > eventsPacket2.transactionID,
584 > )
585 >
586 > s.appendRawHistoryBatches(s.ShardID, branchToken, eventsPacket1)
587 > s.appendRawHistoryBatches(s.ShardID, branchToken, eventsPacket2)
588 > s.appendRawHistoryBatches(s.ShardID, branchToken, eventsPacket3)
589 > protorequire.ProtoSliceEqual(s.T(), eventsPacket1.events, s.listHistoryEvents(s.ShardID, branchToken, common.FirstEventID, 4))
590 > expectedEvents := append(eventsPacket1.events, append(eventsPacket2.events, eventsPacket3.events...)...)
591 > events := s.listAllHistoryEvents(s.ShardID, branchToken)
592 > protorequire.ProtoSliceEqual(s.T(), expectedEvents, events)
593 > }
594
595 func (s *HistoryEventsSuite) TestForkDeleteBranch_DeleteBaseBranchFirst() {
748 branchToken []byte,
749 packet HistoryEventsPacket,
750 > ) { history_store.go
751 > blob, err := s.serializer.SerializeEvents(packet.events)
752 > s.NoError(err)
753 > _, err = s.store.AppendRawHistoryNodes(s.Ctx, &p.AppendRawHistoryNodesRequest{
754 > ShardID: shardID,
755 > BranchToken: branchToken,
756 > NodeID: packet.nodeID,
757 > TransactionID: packet.transactionID,
758 > PrevTransactionID: packet.prevTransactionID,
759 > IsNewBranch: packet.nodeID == common.FirstEventID,
760 > Info: "",
761 > History: blob,
762 > })
763 > s.NoError(err)
764 > }
765
766 func (s *HistoryEventsSuite) forkHistoryBranch(
go.temporal.io/server/common/persistence/history_manager.go 45 introduced LOC · 10 ranges

Open complete file

413 ctx context.Context,
414 request *AppendRawHistoryNodesRequest,
415 > ) (*InternalAppendHistoryNodesRequest, error) { history_manager.go
416 > branch, err := m.GetHistoryBranchUtil().ParseHistoryBranchInfo(request.BranchToken)
417 > if err != nil {
418 return nil, serviceerror.NewInvalidArgument(fmt.Sprintf("unable to parse branch token: %v", err))
419 }
420
421 > if len(request.History.Data) == 0 { history_manager.go
422 return nil, &InvalidPersistenceRequestError{
423 Msg: "events to be appended cannot be empty",
424 }
425 }
426 > sortAncestors(branch.Ancestors) history_manager.go
427 >
428 > nodeID := request.NodeID
429 > if nodeID <= 0 {
430 return nil, &InvalidPersistenceRequestError{
431 Msg: "eventID cannot be less than 1",
433 }
434 // nodeID will be the first eventID
435 > size := len(request.History.Data) history_manager.go
436 > sizeLimit := m.transactionSizeLimit()
437 > if size > sizeLimit {
438 return nil, &TransactionSizeLimitError{
439 Msg: fmt.Sprintf("transaction size of %v bytes exceeds limit of %v bytes", size, sizeLimit),
441 }
442
443 > req := &InternalAppendHistoryNodesRequest{ history_manager.go
444 > BranchToken: request.BranchToken,
445 > IsNewBranch: request.IsNewBranch,
446 > Info: request.Info,
447 > BranchInfo: branch,
448 > Node: InternalHistoryNode{
449 > NodeID: nodeID,
450 > Events: request.History,
451 > PrevTransactionID: request.PrevTransactionID,
452 > TransactionID: request.TransactionID,
453 > },
454 > ShardID: request.ShardID,
455 > }
456 >
457 > if req.IsNewBranch {
458 > // TreeInfo is only needed for new branch
459 > treeInfoBlob, err := m.serializer.HistoryTreeInfoToBlob(&persistencespb.HistoryTreeInfo{
460 > BranchToken: request.BranchToken, // NOTE: this is redundant but double-writing until 1 minor release later
461 > BranchInfo: branch,
462 > ForkTime: timestamp.TimeNowPtrUtc(),
463 > Info: request.Info,
464 > })
465 > if err != nil {
466 return nil, err
467 }
468 > req.TreeInfo = treeInfoBlob history_manager.go
469 }
470
471 > if nodeID < GetBeginNodeID(branch) { history_manager.go
472 return nil, &InvalidPersistenceRequestError{
473 Msg: "cannot append to ancestors' nodes",
501 ctx context.Context,
502 request *AppendRawHistoryNodesRequest,
503 > ) (*AppendHistoryNodesResponse, error) { history_manager.go
504 >
505 > req, err := m.serializeAppendRawHistoryNodesRequest(ctx, request)
506 > if err != nil {
507 return nil, err
508 }
509
510 > err = m.persistence.AppendHistoryNodes(ctx, req) history_manager.go
511 > return &AppendHistoryNodesResponse{
512 > Size: len(request.History.Data),
513 > }, err
514 }
515