Skip to content

Commit

Permalink
Embed value instead of pointer in properties service ReadOptions (#4462)
Browse files Browse the repository at this point in the history
This addresses previous feedback from Jakub

Signed-off-by: Juan Antonio Osorio <[email protected]>
  • Loading branch information
JAORMX authored Sep 13, 2024
1 parent fd300ca commit 50bb587
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions internal/entities/properties/service/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func (psco *CallOptions) getStoreOrTransaction() db.ExtendQuerier {
// This field is used to determine if the service call can return stale data or not.
// This is useful for read calls that can tolerate stale data.
type ReadOptions struct {
*CallOptions
CallOptions
tolerateStaleData bool
}

Expand All @@ -68,15 +68,12 @@ func (psco *ReadOptions) TolerateStaleData() *ReadOptions {
return psco
}

// WithStoreOrTransaction is a function that sets the StoreOrTransaction field in the ReadOptions struct
// WithStoreOrTransaction is a function that sets the StoreOrTransaction field in the CallOptions struct
func (psco *ReadOptions) WithStoreOrTransaction(storeOrTransaction db.ExtendQuerier) *ReadOptions {
if psco == nil {
return nil
}
if psco.CallOptions == nil {
psco.CallOptions = CallBuilder()
}
psco.CallOptions = psco.CallOptions.WithStoreOrTransaction(storeOrTransaction)
psco.storeOrTransaction = storeOrTransaction
return psco
}

Expand All @@ -88,7 +85,7 @@ func (psco *ReadOptions) canTolerateStaleData() bool {
}

func (psco *ReadOptions) getStoreOrTransaction() db.ExtendQuerier {
if psco == nil || psco.CallOptions == nil {
if psco == nil {
return nil
}
return psco.CallOptions.getStoreOrTransaction()
Expand All @@ -98,7 +95,7 @@ func (psco *ReadOptions) getPropertiesServiceCallOptions() *CallOptions {
if psco == nil {
return nil
}
return psco.CallOptions
return &psco.CallOptions
}

type getStoreOrTransaction interface {
Expand Down

0 comments on commit 50bb587

Please sign in to comment.