Skip to content

Commit

Permalink
address review comments; fix compile error.
Browse files Browse the repository at this point in the history
  • Loading branch information
raulk committed Jul 7, 2021
1 parent 96a370d commit 31b64b8
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
4 changes: 3 additions & 1 deletion mount/file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,12 @@ func TestFileMount(t *testing.T) {
require.True(t, stat.Exists)
require.EqualValues(t, size, stat.Size)

// check URL.
require.Equal(t, mnt.Path, mnt.Serialize().Host)

info := mnt.Info()
require.True(t, info.AccessSequential && info.AccessSeek && info.AccessRandom) // all flags true
require.Equal(t, KindLocal, info.Kind)
require.Equal(t, "file://"+mnt.Path, info.URL.String())

reader, err := mnt.Fetch(context.Background())
require.NoError(t, err)
Expand Down
25 changes: 13 additions & 12 deletions shard.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ import (
// waiter encapsulates a context passed by the user, and the channel they want
// the result returned to.
type waiter struct {
// context governing the operation if this is an external op.
ctx context.Context
outCh chan ShardResult
ctx context.Context // governs the op if it's external
outCh chan ShardResult // to send back the result
}

func (w waiter) deliver(res *ShardResult) {
Expand All @@ -27,15 +26,17 @@ func (w waiter) deliver(res *ShardResult) {
type Shard struct {
lk sync.RWMutex

// IMMUTABLE FIELDS: safe to read outside the event loop without a lock.
d *DAGStore
key shard.Key
mount *mount.Upgrader

// MUTABLE FIELDS: cannot read/write outside event loop.
state ShardState
err error // populated if shard state is errored.
indexed bool
// IMMUTABLE FIELDS
// safe to read outside the event loop without a lock
d *DAGStore // backreference
key shard.Key // persisted in PersistedShard.Key
mount *mount.Upgrader // persisted in PersistedShard.URL (underlying)

// MUTABLE FIELDS
// cannot read/write outside event loop.
state ShardState // persisted in PersistedShard.State
err error // populated if shard state is errored; persisted in PersistedShard.Error
indexed bool // persisted in PersistedShard.Indexed

wRegister *waiter
wAcquire []*waiter
Expand Down
3 changes: 2 additions & 1 deletion shard_persist.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ type PersistedShard struct {
}

// MarshalJSON returns a serialized representation of the state. It must be
// called from inside the event loop, as it accesses mutable state.
// called from inside the event loop, as it accesses mutable state, or under a
// shard read lock.
func (s *Shard) MarshalJSON() ([]byte, error) {
u, err := s.d.mounts.Represent(s.mount)
if err != nil {
Expand Down

0 comments on commit 31b64b8

Please sign in to comment.