Skip to content

Commit

Permalink
content: refactored content manager
Browse files Browse the repository at this point in the history
- separated portions that don't require locking into separate struct
  to make it easier to reason about state
- moved iteration-related content to separate file
  • Loading branch information
jkowalski committed Aug 25, 2019
1 parent f32f0ec commit 2b40f53
Show file tree
Hide file tree
Showing 5 changed files with 745 additions and 712 deletions.
6 changes: 3 additions & 3 deletions repo/content/content_index_recovery.go
Expand Up @@ -149,7 +149,7 @@ func decodePostamble(payload []byte) *packContentPostamble {
}
}

func (bm *Manager) buildLocalIndex(pending packIndexBuilder) ([]byte, error) {
func (bm *lockFreeManager) buildLocalIndex(pending packIndexBuilder) ([]byte, error) {
var buf bytes.Buffer
if err := pending.Build(&buf); err != nil {
return nil, errors.Wrap(err, "unable to build local index")
Expand All @@ -159,7 +159,7 @@ func (bm *Manager) buildLocalIndex(pending packIndexBuilder) ([]byte, error) {
}

// appendPackFileIndexRecoveryData appends data designed to help with recovery of pack index in case it gets damaged or lost.
func (bm *Manager) appendPackFileIndexRecoveryData(contentData []byte, pending packIndexBuilder) ([]byte, error) {
func (bm *lockFreeManager) appendPackFileIndexRecoveryData(contentData []byte, pending packIndexBuilder) ([]byte, error) {
// build, encrypt and append local index
localIndexOffset := len(contentData)
localIndex, err := bm.buildLocalIndex(pending)
Expand Down Expand Up @@ -199,7 +199,7 @@ func (bm *Manager) appendPackFileIndexRecoveryData(contentData []byte, pending p
return contentData, nil
}

func (bm *Manager) readPackFileLocalIndex(ctx context.Context, packFile blob.ID, packFileLength int64) ([]byte, error) {
func (bm *lockFreeManager) readPackFileLocalIndex(ctx context.Context, packFile blob.ID, packFileLength int64) ([]byte, error) {
// TODO(jkowalski): optimize read when packFileLength is provided
_ = packFileLength
payload, err := bm.st.GetBlob(ctx, packFile, 0, -1)
Expand Down

0 comments on commit 2b40f53

Please sign in to comment.