Skip to content

Commit

Permalink
[FAB-8821] Documentation corrections
Browse files Browse the repository at this point in the history
Change-Id: I69826a9580b144d4345117e04442ecf942e5a6a9
Signed-off-by: Bob Stasyszyn <Bob.Stasyszyn@securekey.com>
  • Loading branch information
bstasyszyn committed Mar 12, 2018
1 parent 6e67766 commit c1724a6
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 15 deletions.
6 changes: 3 additions & 3 deletions pkg/common/futurevalue/futurevalue.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ func (f *Value) Get() (interface{}, error) {
return value, err
}

// MustGet returns the value. If an error occurred
// during initialization then a panic will occur.
// MustGet returns the value. If an error resulted
// during initialization then this function will panic.
func (f *Value) MustGet() interface{} {
value, err := f.Get()
if err != nil {
Expand All @@ -78,7 +78,7 @@ func (f *Value) MustGet() interface{} {
return value
}

// IsSet returns true if the value has been setl otherwise false
// IsSet returns true if the value has been set, otherwise false is returned
func (f *Value) IsSet() bool {
isSet, _, _ := f.get()
return isSet
Expand Down
2 changes: 1 addition & 1 deletion pkg/common/futurevalue/futurevalue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func ExampleValue_Get() {
go func() {
value, err := fv.Get()
if err != nil {
fmt.Printf("Error returns from Get: %s\n", err)
fmt.Printf("Error returned from Get: %s\n", err)
}
fmt.Println(value)
done <- true
Expand Down
3 changes: 2 additions & 1 deletion pkg/common/lazycache/lazycache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ func ExampleCache_MustGet() {
cache := New("Example_Cache", func(key Key) (interface{}, error) {
return fmt.Sprintf("Value_for_key_%s", key), nil
})
defer cache.Close()

key := NewStringKey("Key1")

Expand All @@ -31,6 +32,7 @@ func ExampleCache_Get() {
}
return fmt.Sprintf("Value_for_key_%s", key), nil
})
defer cache.Close()

value, err := cache.Get(NewStringKey("Key1"))
if err != nil {
Expand All @@ -43,7 +45,6 @@ func ExampleCache_Get() {
fmt.Printf("Error returned: %s\n", err)
}
fmt.Println(value)
cache.Close()
}

func TestGet(t *testing.T) {
Expand Down
10 changes: 5 additions & 5 deletions pkg/common/lazyref/lazyref_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,22 @@ func ExampleReference_expiring() {
}
}

// ExampleReference_refreshing demonstrates a refreshing reference.
// The reference is initialized immediately after creation and
// then refreshed every 2 seconds
// This example demonstrates a refreshing reference.
// The reference is initialized immediately after creation
// and every 2 seconds thereafter.
func ExampleReference_refreshing() {
sequence := 0
ref := New(
func() (interface{}, error) {
sequence++
return fmt.Sprintf("Data_%d", sequence), nil
},
WithRefreshInterval(InitImmediately, time.Second),
WithRefreshInterval(InitImmediately, 2*time.Second),
)

for i := 0; i < 5; i++ {
fmt.Println(ref.MustGet())
time.Sleep(2 * time.Second)
time.Sleep(3 * time.Second)
}
}

Expand Down
11 changes: 6 additions & 5 deletions pkg/common/lazyref/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
// Opt is a reference option
type Opt func(ref *Reference)

// WithIdleExpiration sets the idle-time expiration time for the reference.
// WithIdleExpiration sets the idle-time expiration for the reference.
// The reference is expired after not being accessed for the given duration.
func WithIdleExpiration(expiration time.Duration) Opt {
return func(ref *Reference) {
Expand Down Expand Up @@ -57,10 +57,11 @@ const (
InitImmediately time.Duration = time.Duration(0)
)

// WithRefreshInterval indicates that the reference should be proactively refreshed.
// - initialInit, if greater than or equal to 0, indicates that the reference
// should be initialized after this duration
// - refreshPeriod is the period in which the reference will be refreshed
// WithRefreshInterval specifies that the reference should be proactively refreshed.
// Argument, initialInit, if greater than or equal to 0, indicates that the reference
// should be initialized after this duration. If less than 0, the reference will be
// initialized on first access.
// Argument, refreshPeriod, is the period at which the reference will be refreshed.
// Note that the Finalizer will not be invoked each time the value is refreshed.
func WithRefreshInterval(initialInit, refreshPeriod time.Duration) Opt {
return func(ref *Reference) {
Expand Down

0 comments on commit c1724a6

Please sign in to comment.