control: add diskusage service

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
docker-18.09
Tonis Tiigi 2017-06-07 17:53:36 -07:00
parent 8719505435
commit 45bcca5c80
6 changed files with 1019 additions and 8 deletions

View File

@ -0,0 +1,933 @@
// Code generated by protoc-gen-gogo.
// source: control.proto
// DO NOT EDIT!
/*
Package control is a generated protocol buffer package.
It is generated from these files:
control.proto
It has these top-level messages:
DiskUsageRequest
DiskUsageResponse
UsageRecord
*/
package control
import proto "github.com/gogo/protobuf/proto"
import fmt "fmt"
import math "math"
import strings "strings"
import reflect "reflect"
import (
context "golang.org/x/net/context"
grpc "google.golang.org/grpc"
)
import io "io"
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
type DiskUsageRequest struct {
}
func (m *DiskUsageRequest) Reset() { *m = DiskUsageRequest{} }
func (*DiskUsageRequest) ProtoMessage() {}
func (*DiskUsageRequest) Descriptor() ([]byte, []int) { return fileDescriptorControl, []int{0} }
type DiskUsageResponse struct {
Record []*UsageRecord `protobuf:"bytes,1,rep,name=record" json:"record,omitempty"`
}
func (m *DiskUsageResponse) Reset() { *m = DiskUsageResponse{} }
func (*DiskUsageResponse) ProtoMessage() {}
func (*DiskUsageResponse) Descriptor() ([]byte, []int) { return fileDescriptorControl, []int{1} }
func (m *DiskUsageResponse) GetRecord() []*UsageRecord {
if m != nil {
return m.Record
}
return nil
}
type UsageRecord struct {
ID string `protobuf:"bytes,1,opt,name=ID,proto3" json:"ID,omitempty"`
Mutable bool `protobuf:"varint,2,opt,name=Mutable,proto3" json:"Mutable,omitempty"`
InUse bool `protobuf:"varint,3,opt,name=InUse,proto3" json:"InUse,omitempty"`
Size_ int64 `protobuf:"varint,4,opt,name=Size,proto3" json:"Size,omitempty"`
}
func (m *UsageRecord) Reset() { *m = UsageRecord{} }
func (*UsageRecord) ProtoMessage() {}
func (*UsageRecord) Descriptor() ([]byte, []int) { return fileDescriptorControl, []int{2} }
func (m *UsageRecord) GetID() string {
if m != nil {
return m.ID
}
return ""
}
func (m *UsageRecord) GetMutable() bool {
if m != nil {
return m.Mutable
}
return false
}
func (m *UsageRecord) GetInUse() bool {
if m != nil {
return m.InUse
}
return false
}
func (m *UsageRecord) GetSize_() int64 {
if m != nil {
return m.Size_
}
return 0
}
func init() {
proto.RegisterType((*DiskUsageRequest)(nil), "control.DiskUsageRequest")
proto.RegisterType((*DiskUsageResponse)(nil), "control.DiskUsageResponse")
proto.RegisterType((*UsageRecord)(nil), "control.UsageRecord")
}
func (this *DiskUsageRequest) Equal(that interface{}) bool {
if that == nil {
if this == nil {
return true
}
return false
}
that1, ok := that.(*DiskUsageRequest)
if !ok {
that2, ok := that.(DiskUsageRequest)
if ok {
that1 = &that2
} else {
return false
}
}
if that1 == nil {
if this == nil {
return true
}
return false
} else if this == nil {
return false
}
return true
}
func (this *DiskUsageResponse) Equal(that interface{}) bool {
if that == nil {
if this == nil {
return true
}
return false
}
that1, ok := that.(*DiskUsageResponse)
if !ok {
that2, ok := that.(DiskUsageResponse)
if ok {
that1 = &that2
} else {
return false
}
}
if that1 == nil {
if this == nil {
return true
}
return false
} else if this == nil {
return false
}
if len(this.Record) != len(that1.Record) {
return false
}
for i := range this.Record {
if !this.Record[i].Equal(that1.Record[i]) {
return false
}
}
return true
}
func (this *UsageRecord) Equal(that interface{}) bool {
if that == nil {
if this == nil {
return true
}
return false
}
that1, ok := that.(*UsageRecord)
if !ok {
that2, ok := that.(UsageRecord)
if ok {
that1 = &that2
} else {
return false
}
}
if that1 == nil {
if this == nil {
return true
}
return false
} else if this == nil {
return false
}
if this.ID != that1.ID {
return false
}
if this.Mutable != that1.Mutable {
return false
}
if this.InUse != that1.InUse {
return false
}
if this.Size_ != that1.Size_ {
return false
}
return true
}
func (this *DiskUsageRequest) GoString() string {
if this == nil {
return "nil"
}
s := make([]string, 0, 4)
s = append(s, "&control.DiskUsageRequest{")
s = append(s, "}")
return strings.Join(s, "")
}
func (this *DiskUsageResponse) GoString() string {
if this == nil {
return "nil"
}
s := make([]string, 0, 5)
s = append(s, "&control.DiskUsageResponse{")
if this.Record != nil {
s = append(s, "Record: "+fmt.Sprintf("%#v", this.Record)+",\n")
}
s = append(s, "}")
return strings.Join(s, "")
}
func (this *UsageRecord) GoString() string {
if this == nil {
return "nil"
}
s := make([]string, 0, 8)
s = append(s, "&control.UsageRecord{")
s = append(s, "ID: "+fmt.Sprintf("%#v", this.ID)+",\n")
s = append(s, "Mutable: "+fmt.Sprintf("%#v", this.Mutable)+",\n")
s = append(s, "InUse: "+fmt.Sprintf("%#v", this.InUse)+",\n")
s = append(s, "Size_: "+fmt.Sprintf("%#v", this.Size_)+",\n")
s = append(s, "}")
return strings.Join(s, "")
}
func valueToGoStringControl(v interface{}, typ string) string {
rv := reflect.ValueOf(v)
if rv.IsNil() {
return "nil"
}
pv := reflect.Indirect(rv).Interface()
return fmt.Sprintf("func(v %v) *%v { return &v } ( %#v )", typ, typ, pv)
}
// Reference imports to suppress errors if they are not otherwise used.
var _ context.Context
var _ grpc.ClientConn
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
const _ = grpc.SupportPackageIsVersion4
// Client API for Control service
type ControlClient interface {
DiskUsage(ctx context.Context, in *DiskUsageRequest, opts ...grpc.CallOption) (*DiskUsageResponse, error)
}
type controlClient struct {
cc *grpc.ClientConn
}
func NewControlClient(cc *grpc.ClientConn) ControlClient {
return &controlClient{cc}
}
func (c *controlClient) DiskUsage(ctx context.Context, in *DiskUsageRequest, opts ...grpc.CallOption) (*DiskUsageResponse, error) {
out := new(DiskUsageResponse)
err := grpc.Invoke(ctx, "/control.Control/DiskUsage", in, out, c.cc, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// Server API for Control service
type ControlServer interface {
DiskUsage(context.Context, *DiskUsageRequest) (*DiskUsageResponse, error)
}
func RegisterControlServer(s *grpc.Server, srv ControlServer) {
s.RegisterService(&_Control_serviceDesc, srv)
}
func _Control_DiskUsage_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(DiskUsageRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ControlServer).DiskUsage(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/control.Control/DiskUsage",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ControlServer).DiskUsage(ctx, req.(*DiskUsageRequest))
}
return interceptor(ctx, in, info, handler)
}
var _Control_serviceDesc = grpc.ServiceDesc{
ServiceName: "control.Control",
HandlerType: (*ControlServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "DiskUsage",
Handler: _Control_DiskUsage_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "control.proto",
}
func (m *DiskUsageRequest) 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 *DiskUsageRequest) MarshalTo(dAtA []byte) (int, error) {
var i int
_ = i
var l int
_ = l
return i, nil
}
func (m *DiskUsageResponse) 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 *DiskUsageResponse) MarshalTo(dAtA []byte) (int, error) {
var i int
_ = i
var l int
_ = l
if len(m.Record) > 0 {
for _, msg := range m.Record {
dAtA[i] = 0xa
i++
i = encodeVarintControl(dAtA, i, uint64(msg.Size()))
n, err := msg.MarshalTo(dAtA[i:])
if err != nil {
return 0, err
}
i += n
}
}
return i, nil
}
func (m *UsageRecord) 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 *UsageRecord) MarshalTo(dAtA []byte) (int, error) {
var i int
_ = i
var l int
_ = l
if len(m.ID) > 0 {
dAtA[i] = 0xa
i++
i = encodeVarintControl(dAtA, i, uint64(len(m.ID)))
i += copy(dAtA[i:], m.ID)
}
if m.Mutable {
dAtA[i] = 0x10
i++
if m.Mutable {
dAtA[i] = 1
} else {
dAtA[i] = 0
}
i++
}
if m.InUse {
dAtA[i] = 0x18
i++
if m.InUse {
dAtA[i] = 1
} else {
dAtA[i] = 0
}
i++
}
if m.Size_ != 0 {
dAtA[i] = 0x20
i++
i = encodeVarintControl(dAtA, i, uint64(m.Size_))
}
return i, nil
}
func encodeFixed64Control(dAtA []byte, offset int, v uint64) int {
dAtA[offset] = uint8(v)
dAtA[offset+1] = uint8(v >> 8)
dAtA[offset+2] = uint8(v >> 16)
dAtA[offset+3] = uint8(v >> 24)
dAtA[offset+4] = uint8(v >> 32)
dAtA[offset+5] = uint8(v >> 40)
dAtA[offset+6] = uint8(v >> 48)
dAtA[offset+7] = uint8(v >> 56)
return offset + 8
}
func encodeFixed32Control(dAtA []byte, offset int, v uint32) int {
dAtA[offset] = uint8(v)
dAtA[offset+1] = uint8(v >> 8)
dAtA[offset+2] = uint8(v >> 16)
dAtA[offset+3] = uint8(v >> 24)
return offset + 4
}
func encodeVarintControl(dAtA []byte, offset int, v uint64) int {
for v >= 1<<7 {
dAtA[offset] = uint8(v&0x7f | 0x80)
v >>= 7
offset++
}
dAtA[offset] = uint8(v)
return offset + 1
}
func (m *DiskUsageRequest) Size() (n int) {
var l int
_ = l
return n
}
func (m *DiskUsageResponse) Size() (n int) {
var l int
_ = l
if len(m.Record) > 0 {
for _, e := range m.Record {
l = e.Size()
n += 1 + l + sovControl(uint64(l))
}
}
return n
}
func (m *UsageRecord) Size() (n int) {
var l int
_ = l
l = len(m.ID)
if l > 0 {
n += 1 + l + sovControl(uint64(l))
}
if m.Mutable {
n += 2
}
if m.InUse {
n += 2
}
if m.Size_ != 0 {
n += 1 + sovControl(uint64(m.Size_))
}
return n
}
func sovControl(x uint64) (n int) {
for {
n++
x >>= 7
if x == 0 {
break
}
}
return n
}
func sozControl(x uint64) (n int) {
return sovControl(uint64((x << 1) ^ uint64((int64(x) >> 63))))
}
func (this *DiskUsageRequest) String() string {
if this == nil {
return "nil"
}
s := strings.Join([]string{`&DiskUsageRequest{`,
`}`,
}, "")
return s
}
func (this *DiskUsageResponse) String() string {
if this == nil {
return "nil"
}
s := strings.Join([]string{`&DiskUsageResponse{`,
`Record:` + strings.Replace(fmt.Sprintf("%v", this.Record), "UsageRecord", "UsageRecord", 1) + `,`,
`}`,
}, "")
return s
}
func (this *UsageRecord) String() string {
if this == nil {
return "nil"
}
s := strings.Join([]string{`&UsageRecord{`,
`ID:` + fmt.Sprintf("%v", this.ID) + `,`,
`Mutable:` + fmt.Sprintf("%v", this.Mutable) + `,`,
`InUse:` + fmt.Sprintf("%v", this.InUse) + `,`,
`Size_:` + fmt.Sprintf("%v", this.Size_) + `,`,
`}`,
}, "")
return s
}
func valueToStringControl(v interface{}) string {
rv := reflect.ValueOf(v)
if rv.IsNil() {
return "nil"
}
pv := reflect.Indirect(rv).Interface()
return fmt.Sprintf("*%v", pv)
}
func (m *DiskUsageRequest) 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 ErrIntOverflowControl
}
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: DiskUsageRequest: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: DiskUsageRequest: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
default:
iNdEx = preIndex
skippy, err := skipControl(dAtA[iNdEx:])
if err != nil {
return err
}
if skippy < 0 {
return ErrInvalidLengthControl
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func (m *DiskUsageResponse) 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 ErrIntOverflowControl
}
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: DiskUsageResponse: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: DiskUsageResponse: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Record", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowControl
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= (int(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthControl
}
postIndex := iNdEx + msglen
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Record = append(m.Record, &UsageRecord{})
if err := m.Record[len(m.Record)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipControl(dAtA[iNdEx:])
if err != nil {
return err
}
if skippy < 0 {
return ErrInvalidLengthControl
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func (m *UsageRecord) 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 ErrIntOverflowControl
}
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: UsageRecord: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: UsageRecord: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
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 ErrIntOverflowControl
}
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 ErrInvalidLengthControl
}
postIndex := iNdEx + intStringLen
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.ID = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
case 2:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field Mutable", wireType)
}
var v int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowControl
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
v |= (int(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
m.Mutable = bool(v != 0)
case 3:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field InUse", wireType)
}
var v int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowControl
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
v |= (int(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
m.InUse = bool(v != 0)
case 4:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field Size_", wireType)
}
m.Size_ = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowControl
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.Size_ |= (int64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
default:
iNdEx = preIndex
skippy, err := skipControl(dAtA[iNdEx:])
if err != nil {
return err
}
if skippy < 0 {
return ErrInvalidLengthControl
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func skipControl(dAtA []byte) (n int, err error) {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowControl
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
wireType := int(wire & 0x7)
switch wireType {
case 0:
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowControl
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
iNdEx++
if dAtA[iNdEx-1] < 0x80 {
break
}
}
return iNdEx, nil
case 1:
iNdEx += 8
return iNdEx, nil
case 2:
var length int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowControl
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
length |= (int(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
iNdEx += length
if length < 0 {
return 0, ErrInvalidLengthControl
}
return iNdEx, nil
case 3:
for {
var innerWire uint64
var start int = iNdEx
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowControl
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
innerWire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
innerWireType := int(innerWire & 0x7)
if innerWireType == 4 {
break
}
next, err := skipControl(dAtA[start:])
if err != nil {
return 0, err
}
iNdEx = start + next
}
return iNdEx, nil
case 4:
return iNdEx, nil
case 5:
iNdEx += 4
return iNdEx, nil
default:
return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
}
}
panic("unreachable")
}
var (
ErrInvalidLengthControl = fmt.Errorf("proto: negative length found during unmarshaling")
ErrIntOverflowControl = fmt.Errorf("proto: integer overflow")
)
func init() { proto.RegisterFile("control.proto", fileDescriptorControl) }
var fileDescriptorControl = []byte{
// 256 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xe2, 0xe2, 0x4d, 0xce, 0xcf, 0x2b,
0x29, 0xca, 0xcf, 0xd1, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x87, 0x72, 0x95, 0x84, 0xb8,
0x04, 0x5c, 0x32, 0x8b, 0xb3, 0x43, 0x8b, 0x13, 0xd3, 0x53, 0x83, 0x52, 0x0b, 0x4b, 0x53, 0x8b,
0x4b, 0x94, 0x1c, 0xb9, 0x04, 0x91, 0xc4, 0x8a, 0x0b, 0xf2, 0xf3, 0x8a, 0x53, 0x85, 0x74, 0xb8,
0xd8, 0x8a, 0x52, 0x93, 0xf3, 0x8b, 0x52, 0x24, 0x18, 0x15, 0x98, 0x35, 0xb8, 0x8d, 0x44, 0xf4,
0x60, 0x26, 0x42, 0xd5, 0x81, 0xe4, 0x82, 0xa0, 0x6a, 0x94, 0x12, 0xb9, 0xb8, 0x91, 0x84, 0x85,
0xf8, 0xb8, 0x98, 0x3c, 0x5d, 0x24, 0x18, 0x15, 0x18, 0x35, 0x38, 0x83, 0x98, 0x3c, 0x5d, 0x84,
0x24, 0xb8, 0xd8, 0x7d, 0x4b, 0x4b, 0x12, 0x93, 0x72, 0x52, 0x25, 0x98, 0x14, 0x18, 0x35, 0x38,
0x82, 0x60, 0x5c, 0x21, 0x11, 0x2e, 0x56, 0xcf, 0xbc, 0xd0, 0xe2, 0x54, 0x09, 0x66, 0xb0, 0x38,
0x84, 0x23, 0x24, 0xc4, 0xc5, 0x12, 0x9c, 0x59, 0x95, 0x2a, 0xc1, 0xa2, 0xc0, 0xa8, 0xc1, 0x1c,
0x04, 0x66, 0x1b, 0xf9, 0x72, 0xb1, 0x3b, 0x43, 0x5c, 0x20, 0xe4, 0xc4, 0xc5, 0x09, 0x77, 0xb0,
0x90, 0x24, 0xdc, 0x61, 0xe8, 0x1e, 0x93, 0x92, 0xc2, 0x26, 0x05, 0xf1, 0x9f, 0x93, 0xce, 0x85,
0x87, 0x72, 0x0c, 0x37, 0x1e, 0xca, 0x31, 0x7c, 0x78, 0x28, 0xc7, 0xd8, 0xf0, 0x48, 0x8e, 0x71,
0xc5, 0x23, 0x39, 0xc6, 0x13, 0x8f, 0xe4, 0x18, 0x2f, 0x3c, 0x92, 0x63, 0x7c, 0xf0, 0x48, 0x8e,
0xf1, 0xc5, 0x23, 0x39, 0x86, 0x0f, 0x8f, 0xe4, 0x18, 0x27, 0x3c, 0x96, 0x63, 0x48, 0x62, 0x03,
0x07, 0xa3, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0xee, 0x24, 0x0f, 0x0a, 0x57, 0x01, 0x00, 0x00,
}

View File

@ -0,0 +1,22 @@
syntax = "proto3";
package control;
service Control {
rpc DiskUsage(DiskUsageRequest) returns (DiskUsageResponse);
}
message DiskUsageRequest {
}
message DiskUsageResponse {
repeated UsageRecord record = 1;
}
message UsageRecord {
string ID = 1;
bool Mutable = 2;
bool InUse = 3;
int64 Size = 4;
}

View File

@ -0,0 +1,3 @@
package control
//go:generate protoc --gogoslick_out=plugins=grpc:. control.proto

16
cache/manager.go vendored
View File

@ -47,10 +47,10 @@ type Manager interface {
}
type UsageInfo struct {
ID string
Active bool
InUse bool
Size int64
ID string
Mutable bool
InUse bool
Size int64
// Meta string
// LastUsed time.Time
}
@ -215,10 +215,10 @@ func (cm *cacheManager) DiskUsage(ctx context.Context) ([]*UsageInfo, error) {
for id, cr := range cm.records {
cr.mu.Lock()
c := &UsageInfo{
ID: id,
Active: cr.mutable,
InUse: len(cr.refs) > 0,
Size: cr.size,
ID: id,
Mutable: cr.mutable,
InUse: len(cr.refs) > 0,
Size: cr.size,
}
if cr.mutable && len(cr.refs) > 0 && !cr.frozen {
c.Size = 0 // size can not be determined because it is changing

52
control/control.go Normal file
View File

@ -0,0 +1,52 @@
package control
import (
"github.com/containerd/containerd/snapshot"
controlapi "github.com/tonistiigi/buildkit_poc/api/services/control"
"github.com/tonistiigi/buildkit_poc/cache"
"github.com/tonistiigi/buildkit_poc/source"
"github.com/tonistiigi/buildkit_poc/worker"
"golang.org/x/net/context"
"google.golang.org/grpc"
)
type Opt struct {
Snapshotter snapshot.Snapshotter
CacheManager cache.Manager
Worker worker.Worker
SourceManager *source.Manager
}
type Controller struct {
opt Opt
}
func NewController(opt Opt) (*Controller, error) {
c := &Controller{
opt: opt,
}
return c, nil
}
func (c *Controller) Register(server *grpc.Server) error {
controlapi.RegisterControlServer(server, c)
return nil
}
func (c *Controller) DiskUsage(ctx context.Context, _ *controlapi.DiskUsageRequest) (*controlapi.DiskUsageResponse, error) {
du, err := c.opt.CacheManager.DiskUsage(ctx)
if err != nil {
return nil, err
}
resp := &controlapi.DiskUsageResponse{}
for _, r := range du {
resp.Record = append(resp.Record, &controlapi.UsageRecord{
ID: r.ID,
Mutable: r.Mutable,
InUse: r.InUse,
Size_: r.Size,
})
}
return resp, nil
}

View File

@ -51,6 +51,7 @@ func TestControl(t *testing.T) {
Snapshotter: snapshotter,
Root: filepath.Join(tmpdir, "cachemanager"),
})
assert.NoError(t, err)
sm, err := source.NewManager()
assert.NoError(t, err)