Skip to content

Commit f5142cb

Browse files
committed
additional comments
Signed-off-by: Angelo De Caro <[email protected]>
1 parent ad41669 commit f5142cb

File tree

4 files changed

+14
-2
lines changed

4 files changed

+14
-2
lines changed

platform/view/services/view/child.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ type ParentContext interface {
2020
PutSession(caller view.View, party view.Identity, session view.Session) error
2121
}
2222

23+
// ChildContext is a view context with a parent.
24+
// It allows the developer to override session and initiator.
25+
// It also supports error callbacks.
2326
type ChildContext struct {
2427
Parent ParentContext
2528

@@ -28,18 +31,22 @@ type ChildContext struct {
2831
errorCallbackFuncs []func()
2932
}
3033

34+
// NewChildContextFromParent return a new ChildContext from the given parent
3135
func NewChildContextFromParent(parentContext ParentContext) *ChildContext {
3236
return NewChildContext(parentContext, nil, nil, nil)
3337
}
3438

39+
// NewChildContextFromParentAndSession return a new ChildContext from the given parent and session
3540
func NewChildContextFromParentAndSession(parentContext ParentContext, session view.Session) *ChildContext {
3641
return NewChildContext(parentContext, session, nil, nil)
3742
}
3843

44+
// NewChildContextFromParentAndInitiator return a new ChildContext from the given parent and initiator view
3945
func NewChildContextFromParentAndInitiator(parentContext ParentContext, initiator view.View) *ChildContext {
4046
return NewChildContext(parentContext, nil, initiator, nil)
4147
}
4248

49+
// NewChildContext return a new ChildContext from the given arguments
4350
func NewChildContext(parentContext ParentContext, session view.Session, initiator view.View, errorCallbackFuncs ...func()) *ChildContext {
4451
return &ChildContext{Parent: parentContext, session: session, initiator: initiator, errorCallbackFuncs: errorCallbackFuncs}
4552
}

platform/view/services/view/context.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ type Context struct {
6363
localIdentityChecker LocalIdentityChecker
6464
}
6565

66+
// NewContextForInitiator returns a new Context for an initiator view
6667
func NewContextForInitiator(
6768
contextID string,
6869
context context.Context,
@@ -102,6 +103,7 @@ func NewContextForInitiator(
102103
return ctx, nil
103104
}
104105

106+
// NewContext returns a new Context
105107
func NewContext(
106108
context context.Context,
107109
sp services.Provider,

platform/view/services/view/view.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import (
1616
"go.opentelemetry.io/otel/trace"
1717
)
1818

19+
// ViewContext is an alias for view.Context
20+
//
1921
//go:generate counterfeiter -o mock/context.go -fake-name Context . ViewContext
2022
type ViewContext = view.Context
2123

platform/view/view/context.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,16 @@ func WithViewCall(f func(Context) (interface{}, error)) RunViewOption {
5959
}
6060
}
6161

62-
// WithSameContext is used to reuse the context
62+
// WithSameContext is used to reuse the view context
6363
func WithSameContext() RunViewOption {
6464
return func(o *RunViewOptions) error {
6565
o.SameContext = true
6666
return nil
6767
}
6868
}
6969

70-
// WithContext is used to pass a different context to the view
70+
// WithContext is used to pass a different context.Context to the view.
71+
// It includes the effect of WithSameContext as well.
7172
func WithContext(ctx context.Context) RunViewOption {
7273
return func(o *RunViewOptions) error {
7374
o.SameContext = true

0 commit comments

Comments
 (0)