File: stream_visitor_lazy.go

package info (click to toggle)
gitlab-agent 16.11.5-1
  • links: PTS, VCS
  • area: contrib
  • in suites: experimental
  • size: 7,072 kB
  • sloc: makefile: 193; sh: 55; ruby: 3
file content (17 lines) | stat: -rw-r--r-- 362 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
package grpctool

import (
	"sync"

	"google.golang.org/protobuf/proto"
)

func NewLazyStreamVisitor(streamMessage proto.Message) func() *StreamVisitor {
	return sync.OnceValue(func() *StreamVisitor {
		sv, err := NewStreamVisitor(streamMessage)
		if err != nil {
			panic(err) // this will never panic as long as the proto file is correct
		}
		return sv
	})
}