From e78ec2aab69068074038ee01bc89b75254a044b7 Mon Sep 17 00:00:00 2001 From: Brian Goff Date: Thu, 17 May 2018 10:13:25 -0400 Subject: [PATCH] Add partial log metadata to log driver proto Signed-off-by: Brian Goff --- api/types/plugins/logdriver/entry.pb.go | 297 ++++++++++++++++++++++-- api/types/plugins/logdriver/entry.proto | 8 + 2 files changed, 290 insertions(+), 15 deletions(-) diff --git a/api/types/plugins/logdriver/entry.pb.go b/api/types/plugins/logdriver/entry.pb.go index 5d7d8b4c41..5ced16895c 100644 --- a/api/types/plugins/logdriver/entry.pb.go +++ b/api/types/plugins/logdriver/entry.pb.go @@ -10,6 +10,7 @@ It has these top-level messages: LogEntry + PartialLogEntryMetadata */ package logdriver @@ -31,10 +32,11 @@ var _ = math.Inf const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package type LogEntry struct { - Source string `protobuf:"bytes,1,opt,name=source,proto3" json:"source,omitempty"` - TimeNano int64 `protobuf:"varint,2,opt,name=time_nano,json=timeNano,proto3" json:"time_nano,omitempty"` - Line []byte `protobuf:"bytes,3,opt,name=line,proto3" json:"line,omitempty"` - Partial bool `protobuf:"varint,4,opt,name=partial,proto3" json:"partial,omitempty"` + Source string `protobuf:"bytes,1,opt,name=source,proto3" json:"source,omitempty"` + TimeNano int64 `protobuf:"varint,2,opt,name=time_nano,json=timeNano,proto3" json:"time_nano,omitempty"` + Line []byte `protobuf:"bytes,3,opt,name=line,proto3" json:"line,omitempty"` + Partial bool `protobuf:"varint,4,opt,name=partial,proto3" json:"partial,omitempty"` + PartialLogMetadata *PartialLogEntryMetadata `protobuf:"bytes,5,opt,name=partial_log_metadata,json=partialLogMetadata" json:"partial_log_metadata,omitempty"` } func (m *LogEntry) Reset() { *m = LogEntry{} } @@ -70,8 +72,48 @@ func (m *LogEntry) GetPartial() bool { return false } +func (m *LogEntry) GetPartialLogMetadata() *PartialLogEntryMetadata { + if m != nil { + return m.PartialLogMetadata + } + return nil +} + +type PartialLogEntryMetadata struct { + Last bool `protobuf:"varint,1,opt,name=last,proto3" json:"last,omitempty"` + Id string `protobuf:"bytes,2,opt,name=id,proto3" json:"id,omitempty"` + Ordinal int32 `protobuf:"varint,3,opt,name=ordinal,proto3" json:"ordinal,omitempty"` +} + +func (m *PartialLogEntryMetadata) Reset() { *m = PartialLogEntryMetadata{} } +func (m *PartialLogEntryMetadata) String() string { return proto.CompactTextString(m) } +func (*PartialLogEntryMetadata) ProtoMessage() {} +func (*PartialLogEntryMetadata) Descriptor() ([]byte, []int) { return fileDescriptorEntry, []int{1} } + +func (m *PartialLogEntryMetadata) GetLast() bool { + if m != nil { + return m.Last + } + return false +} + +func (m *PartialLogEntryMetadata) GetId() string { + if m != nil { + return m.Id + } + return "" +} + +func (m *PartialLogEntryMetadata) GetOrdinal() int32 { + if m != nil { + return m.Ordinal + } + return 0 +} + func init() { proto.RegisterType((*LogEntry)(nil), "LogEntry") + proto.RegisterType((*PartialLogEntryMetadata)(nil), "PartialLogEntryMetadata") } func (m *LogEntry) Marshal() (dAtA []byte, err error) { size := m.Size() @@ -115,6 +157,55 @@ func (m *LogEntry) MarshalTo(dAtA []byte) (int, error) { } i++ } + if m.PartialLogMetadata != nil { + dAtA[i] = 0x2a + i++ + i = encodeVarintEntry(dAtA, i, uint64(m.PartialLogMetadata.Size())) + n1, err := m.PartialLogMetadata.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n1 + } + return i, nil +} + +func (m *PartialLogEntryMetadata) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *PartialLogEntryMetadata) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if m.Last { + dAtA[i] = 0x8 + i++ + if m.Last { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i++ + } + if len(m.Id) > 0 { + dAtA[i] = 0x12 + i++ + i = encodeVarintEntry(dAtA, i, uint64(len(m.Id))) + i += copy(dAtA[i:], m.Id) + } + if m.Ordinal != 0 { + dAtA[i] = 0x18 + i++ + i = encodeVarintEntry(dAtA, i, uint64(m.Ordinal)) + } return i, nil } @@ -162,6 +253,26 @@ func (m *LogEntry) Size() (n int) { if m.Partial { n += 2 } + if m.PartialLogMetadata != nil { + l = m.PartialLogMetadata.Size() + n += 1 + l + sovEntry(uint64(l)) + } + return n +} + +func (m *PartialLogEntryMetadata) Size() (n int) { + var l int + _ = l + if m.Last { + n += 2 + } + l = len(m.Id) + if l > 0 { + n += 1 + l + sovEntry(uint64(l)) + } + if m.Ordinal != 0 { + n += 1 + sovEntry(uint64(m.Ordinal)) + } return n } @@ -306,6 +417,157 @@ func (m *LogEntry) Unmarshal(dAtA []byte) error { } } m.Partial = bool(v != 0) + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PartialLogMetadata", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEntry + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthEntry + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.PartialLogMetadata == nil { + m.PartialLogMetadata = &PartialLogEntryMetadata{} + } + if err := m.PartialLogMetadata.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipEntry(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthEntry + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *PartialLogEntryMetadata) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEntry + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: PartialLogEntryMetadata: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PartialLogEntryMetadata: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Last", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEntry + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + m.Last = bool(v != 0) + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEntry + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEntry + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Id = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Ordinal", wireType) + } + m.Ordinal = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEntry + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Ordinal |= (int32(b) & 0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipEntry(dAtA[iNdEx:]) @@ -435,15 +697,20 @@ var ( func init() { proto.RegisterFile("entry.proto", fileDescriptorEntry) } var fileDescriptorEntry = []byte{ - // 149 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xe2, 0xe2, 0x4e, 0xcd, 0x2b, 0x29, - 0xaa, 0xd4, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x57, 0xca, 0xe5, 0xe2, 0xf0, 0xc9, 0x4f, 0x77, 0x05, - 0x89, 0x08, 0x89, 0x71, 0xb1, 0x15, 0xe7, 0x97, 0x16, 0x25, 0xa7, 0x4a, 0x30, 0x2a, 0x30, 0x6a, - 0x70, 0x06, 0x41, 0x79, 0x42, 0xd2, 0x5c, 0x9c, 0x25, 0x99, 0xb9, 0xa9, 0xf1, 0x79, 0x89, 0x79, - 0xf9, 0x12, 0x4c, 0x0a, 0x8c, 0x1a, 0xcc, 0x41, 0x1c, 0x20, 0x01, 0xbf, 0xc4, 0xbc, 0x7c, 0x21, - 0x21, 0x2e, 0x96, 0x9c, 0xcc, 0xbc, 0x54, 0x09, 0x66, 0x05, 0x46, 0x0d, 0x9e, 0x20, 0x30, 0x5b, - 0x48, 0x82, 0x8b, 0xbd, 0x20, 0xb1, 0xa8, 0x24, 0x33, 0x31, 0x47, 0x82, 0x45, 0x81, 0x51, 0x83, - 0x23, 0x08, 0xc6, 0x75, 0xe2, 0x39, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, - 0xe4, 0x18, 0x93, 0xd8, 0xc0, 0x6e, 0x30, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0x2d, 0x24, 0x5a, - 0xd4, 0x92, 0x00, 0x00, 0x00, + // 237 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x74, 0x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 0xc2, 0xb5, 0x93, 0x24, 0x87, 0xd6, 0x79, 0xea, 0x92, 0xfb, 0xca, 0xe4, 0x7a, + 0xb3, 0xfd, 0x1c, 0x6b, 0xf8, 0x1a, 0x6b, 0xf8, 0x1e, 0x6b, 0x78, 0x59, 0xa7, 0x4b, 0x5d, 0xff, + 0x04, 0x00, 0x00, 0xff, 0xff, 0x8f, 0xed, 0x9f, 0xb6, 0x38, 0x01, 0x00, 0x00, } diff --git a/api/types/plugins/logdriver/entry.proto b/api/types/plugins/logdriver/entry.proto index a4e96ea5f4..75be3d6416 100644 --- a/api/types/plugins/logdriver/entry.proto +++ b/api/types/plugins/logdriver/entry.proto @@ -5,4 +5,12 @@ message LogEntry { int64 time_nano = 2; bytes line = 3; bool partial = 4; + PartialLogEntryMetadata partial_log_metadata = 5; } + +message PartialLogEntryMetadata { + bool last = 1; + string id = 2; + int32 ordinal = 3; +} +