コード例 #1
0
ファイル: groupcache_test.go プロジェクト: hefju/groupcache
// tests that a Getter's Get method is only called once with two
// outstanding callers.  This is the proto variant.
func TestGetDupSuppressProto(t *testing.T) {
	once.Do(testSetup)
	// Start two getters. The first should block (waiting reading
	// from stringc) and the second should latch on to the first
	// one.
	resc := make(chan *testpb.TestMessage, 2)
	for i := 0; i < 2; i++ {
		go func() {
			tm := new(testpb.TestMessage)
			if err := protoGroup.Get(dummyCtx, fromChan, ProtoSink(tm)); err != nil {
				tm.Name = proto.String("ERROR:" + err.Error())
			}
			resc <- tm
		}()
	}

	// Wait a bit so both goroutines get merged together via
	// singleflight.
	// TODO(bradfitz): decide whether there are any non-offensive
	// debug/test hooks that could be added to singleflight to
	// make a sleep here unnecessary.
	time.Sleep(250 * time.Millisecond)

	// Unblock the first getter, which should unblock the second
	// as well.
	stringc <- "Fluffy"
	want := &testpb.TestMessage{
		Name: proto.String("ECHO:Fluffy"),
		City: proto.String("SOME-CITY"),
	}
	for i := 0; i < 2; i++ {
		select {
		case v := <-resc:
			if !reflect.DeepEqual(v, want) {
				t.Errorf(" Got: %v\nWant: %v", proto.CompactTextString(v), proto.CompactTextString(want))
			}
		case <-time.After(5 * time.Second):
			t.Errorf("timeout waiting on getter #%d of 2", i+1)
		}
	}
}
コード例 #2
0
ファイル: protobuf.go プロジェクト: yunabe/codelab
func main() {
	p := Person{
		Name: proto.String("Taro Yamada"),
		Age:  proto.Int32(8),
	}

	pet := Pet{Name: proto.String("Mike")}
	p.Pet = append(p.Pet, &pet)
	fmt.Println("-- p.String()  --")
	fmt.Println(p.String())
	fmt.Println("-- MarshalText --")
	fmt.Print(PrintToString(&p)) // not compact

	fmt.Println("-- Marshal --")
	m, _ := proto.Marshal(&p)
	fmt.Println(m)

	fmt.Println("-- CompactTextString --")
	fmt.Println(proto.CompactTextString(&p))
}
コード例 #3
0
ファイル: msg.pb.go プロジェクト: dcjones/doozer
func (this *request) String() string { return proto.CompactTextString(this) }
コード例 #4
0
ファイル: urlfetch_service.pb.go プロジェクト: LeXa4894/test
func (m *URLFetchResponse) String() string { return proto.CompactTextString(m) }
コード例 #5
0
ファイル: urlfetch_service.pb.go プロジェクト: LeXa4894/test
func (m *URLFetchServiceError) String() string { return proto.CompactTextString(m) }
コード例 #6
0
func (m *MgxBidRequest) String() string { return proto.CompactTextString(m) }
コード例 #7
0
func (m *RenewDelegationTokenRequestProto) String() string { return proto.CompactTextString(m) }
コード例 #8
0
func (m *TokenProto) String() string { return proto.CompactTextString(m) }
コード例 #9
0
ファイル: mesos.pb.go プロジェクト: nekto0n/gomes
func (m *Attribute) String() string { return proto.CompactTextString(m) }
コード例 #10
0
ファイル: mesos.pb.go プロジェクト: nekto0n/gomes
func (m *Value_Text) String() string { return proto.CompactTextString(m) }
コード例 #11
0
ファイル: mesos.pb.go プロジェクト: nekto0n/gomes
func (m *SlaveInfo) String() string { return proto.CompactTextString(m) }
コード例 #12
0
ファイル: mesos.pb.go プロジェクト: nekto0n/gomes
func (m *MasterInfo) String() string { return proto.CompactTextString(m) }
コード例 #13
0
ファイル: mesos.pb.go プロジェクト: nekto0n/gomes
func (m *ExecutorInfo) String() string { return proto.CompactTextString(m) }
コード例 #14
0
ファイル: mesos.pb.go プロジェクト: nekto0n/gomes
func (m *CommandInfo_URI) String() string { return proto.CompactTextString(m) }
コード例 #15
0
ファイル: mesos.pb.go プロジェクト: nekto0n/gomes
func (m *FrameworkInfo) String() string { return proto.CompactTextString(m) }
コード例 #16
0
ファイル: state.pb.go プロジェクト: hardiku/gozer
func (m *Entry) String() string { return proto.CompactTextString(m) }
コード例 #17
0
ファイル: state.pb.go プロジェクト: hardiku/gozer
func (m *Operation) String() string { return proto.CompactTextString(m) }
コード例 #18
0
ファイル: mesos.pb.go プロジェクト: nekto0n/gomes
func (m *Resource) String() string { return proto.CompactTextString(m) }
コード例 #19
0
func (m *GetDelegationTokenResponseProto) String() string { return proto.CompactTextString(m) }
コード例 #20
0
ファイル: mesos.pb.go プロジェクト: nekto0n/gomes
func (m *ResourceStatistics) String() string { return proto.CompactTextString(m) }
コード例 #21
0
func (m *MgxBidRequest_AdSlotUnion) String() string { return proto.CompactTextString(m) }
コード例 #22
0
func (this *VoiceModeControl) String() string { return proto.CompactTextString(this) }
コード例 #23
0
ファイル: addservice.pb.go プロジェクト: pguelpa/go-rpcgen
func (this *SumMessage) String() string { return proto.CompactTextString(this) }
コード例 #24
0
func (this *SubChannelControlInfo) String() string { return proto.CompactTextString(this) }
コード例 #25
0
ファイル: urlfetch_service.pb.go プロジェクト: LeXa4894/test
func (m *URLFetchRequest) String() string { return proto.CompactTextString(m) }
コード例 #26
0
func (this *ChannelSimpleInfo) String() string { return proto.CompactTextString(this) }
コード例 #27
0
ファイル: rproto.pb.go プロジェクト: jbeshir/unanimity
func (m *Forward) String() string { return proto.CompactTextString(m) }
コード例 #28
0
func (this *FontStyleInfo) String() string { return proto.CompactTextString(this) }
コード例 #29
0
ファイル: msg.pb.go プロジェクト: dcjones/doozer
func (this *response) String() string { return proto.CompactTextString(this) }
コード例 #30
0
func (this *MicQueueOptions) String() string { return proto.CompactTextString(this) }