protocol

package
v0.1.23-oss Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 3, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrResultWait   = errors.New("waiting for the request result")
	ErrResultFailed = errors.Join(syscall.ECONNREFUSED, errors.New("fetch failed"))
)

Functions

func ReadNotifyUseMessage

func ReadNotifyUseMessage(r io.Reader) (entities.Hash, error)

func WriteCheckStatusReq

func WriteCheckStatusReq(w io.Writer, reqID RequestID) error

func WriteCheckStatusResp

func WriteCheckStatusResp(w io.Writer, reqID RequestID, result ResultType, errCode int32) error

func WriteFetchCASBlobReq

func WriteFetchCASBlobReq(w io.Writer, req *FetchCASBlobReq) error

func WriteFetchObjectReq

func WriteFetchObjectReq(w io.Writer, req *FetchObjectReq) error

func WriteFetchObjectResp

func WriteFetchObjectResp(w io.Writer, resp *FetchObjectResp, objType RequestObjectType) error

func WriteFetchStatReq

func WriteFetchStatReq(w io.Writer, req *FetchStatReq) error

func WriteFetchStatResp

func WriteFetchStatResp(w io.Writer, resp *FetchStatResp) error

func WriteSimpleUdsResp

func WriteSimpleUdsResp(w io.Writer, respType MessageType, reqID RequestID, result ResultType) error

func WriteUdsIdentityGetReq

func WriteUdsIdentityGetReq(w io.Writer, req *UdsIdentityGetReq) error

func WriteUdsIdentityGetResp

func WriteUdsIdentityGetResp(w io.Writer, resp *UdsIdentityGetResp) error

func WriteUdsIdentityPutReq

func WriteUdsIdentityPutReq(w io.Writer, req *UdsIdentityPutReq) error

func WriteUdsInitDeeptreeReq

func WriteUdsInitDeeptreeReq(w io.Writer, req *UdsInitDeeptreeReq) error

func WriteUdsInitDeeptreeResp

func WriteUdsInitDeeptreeResp(w io.Writer, reqID RequestID, result ResultType, hash entities.Hash) error

func WriteUdsMapResultsReq

func WriteUdsMapResultsReq(w io.Writer, req *UdsMapResultsReq) error

func WriteUdsMapResultsResp

func WriteUdsMapResultsResp(w io.Writer, reqID RequestID, result ResultType, hashes []entities.Hash) error

func WriteUdsPutInMapReq

func WriteUdsPutInMapReq(w io.Writer, req *UdsPutInMapReq) error

Types

type BinaryObjectType

type BinaryObjectType byte
const (
	BinaryBlob   BinaryObjectType = 0x01
	BinaryObject BinaryObjectType = 0x02
)

type CASCacheman

type CASCacheman interface {
	FetchGitObjectRequest(key entities.Hash) (cacheman.ResultType, error)
	FetchObjectRequest(key entities.Hash, objType cacheman.RequestObjectType) (cacheman.ResultType, error)
	FetchStatRequest(key entities.Hash) (entities.StatInfo, error)
	SendNewObject(key entities.Hash, objType cacheman.RequestObjectType) error
	SendNotifyUse(key entities.Hash) error

	Close() error
}

type CacheManStats

type CacheManStats struct {
	Connected    bool
	TotalSize    int64
	LRUSize      int64
	LocalCount   int64
	IndexCount   int64
	GCStart      time.Time
	GCEnd        time.Time
	EvictStart   time.Time
	EvictEnd     time.Time
	EvictCount   int64
	OldestObject time.Time
	ClientStat
	FetchBlobs    *QueueStat
	FetchTrees    *QueueStat
	FetchObjects  *QueueStat
	FetchARIs     *QueueStat
	FetchCASBlobs *QueueStat
	FetchMaps     *QueueStat
	OverallPushStat
	PushBlobs   PushGroupStat
	PushObjects PushGroupStat
	PushTrees   PushGroupStat
	PushRefs    PushGroupStat
	PushMaps    PushGroupStat
	Phony       PushGroupStat
	Execute     ExecStat
	Fallback    FallbackStats
}

type CheckStatusReq

type CheckStatusReq struct {
	RequestID RequestID
}

func ReadCheckStatusReq

func ReadCheckStatusReq(r io.Reader) (*CheckStatusReq, error)

type CheckStatusResp

type CheckStatusResp struct {
	RequestID RequestID
	Result    ResultType
	ErrorCode int32
}

func ReadCheckStatusResp

func ReadCheckStatusResp(r io.Reader) (*CheckStatusResp, error)

type CleanReq

type CleanReq struct {
	Blobs   bool
	Objects bool
	Hashes  []string
}

type ClientStat

type ClientStat struct {
	BytesSent     int64
	LastSent      time.Time
	BytesReceived int64
	LastReceived  time.Time
}

type ExecStat

type ExecStat struct {
	Request int64
	Success int64
	Failed  int64
}

type ExecuteRequest

type ExecuteRequest struct {
	EvalRequest    entities.Hash
	Patches        []entities.Hash
	StoreMapResult bool
	PrefetchInputs bool
}

type ExecutionStat

type ExecutionStat struct {
	Request atomic.Int64
	Success atomic.Int64
	Failed  atomic.Int64
}

type FallbackStats

type FallbackStats struct {
	Methods map[string]int64 `json:"methods"`
	Types   map[string]int64 `json:"types"`
}

type FetchARIReq

type FetchARIReq struct {
	RequestID RequestID
	ARI       string
}

func ReadFetchARIReq

func ReadFetchARIReq(r io.Reader) (*FetchARIReq, error)

type FetchCASBlobReq

type FetchCASBlobReq struct {
	RequestID RequestID
	SHA256    entities.SHA256
	Size      int64
}

func ReadFetchCASBlobReq

func ReadFetchCASBlobReq(r io.Reader) (*FetchCASBlobReq, error)

type FetchObjectReq

type FetchObjectReq struct {
	RequestID RequestID
	Hash      entities.Hash
}

func ReadFetchObjectReq

func ReadFetchObjectReq(r io.Reader) (*FetchObjectReq, error)

type FetchObjectResp

type FetchObjectResp struct {
	RequestID RequestID
	Result    ResultType
}

func ReadFetchCASBlobResp

func ReadFetchCASBlobResp(r io.Reader) (*FetchObjectResp, error)

type FetchStatReq

type FetchStatReq struct {
	RequestID RequestID
	Hash      entities.Hash
}

type FetchStatResp

type FetchStatResp struct {
	RequestID  RequestID
	Result     ResultType
	Size       int64
	Mode       uint32
	ObjectType BinaryObjectType
}

type GetRefsReq

type GetRefsReq struct {
	Server  string
	Project string
	Refs    []string
}

type HTTP

type HTTP interface {
	GetRefs(server string, project string, refs []string) ([]entities.Hash, error)
	PutRefs(server string, project string, refs []entities.RefHash, blocking bool) error
	SearchRefs(server string, project string, refPrefix string, limit int) ([]entities.ProjectRefHash, error)
	UseMany(hashes []entities.Hash) error
	WaitIdle(timeout time.Duration) error
	Clean(req CleanReq) error
	SendNewMap(from, to entities.Hash, localOnly bool) error
	FetchMapRequest(key entities.Hash) error
	MapResults(from entities.Hash) ([]entities.Hash, error)
	Execute(req entities.Hash, patches []entities.Hash, storeMapResult, PrefetchInputs bool) (resp entities.Hash, err error)
	WaitFor(timeout time.Duration, priority float64, objects []entities.Hash) (err error)
	Stats() (CacheManStats, error)
	KeepAlive(key entities.Hash) error
	IsObjectRemote(key entities.Hash) (bool, error)
	StartGC() error
	Prefetch(blobs, objects []entities.Hash, priority float64) error
	PushBuildMetrics(req *PushBuildMetricsReq) error
}

type IdentityGetReq

type IdentityGetReq struct {
	SHA1 entities.Hash
}

type IdentityGetResp

type IdentityGetResp struct {
	Found  bool
	SHA256 string
	Size   int64
	Type   int // 0: File, 1: Symlink, 2: Directory
}

type IdentityPutReq

type IdentityPutReq struct {
	SHA1   entities.Hash
	SHA256 string
	Size   int64
	Type   int // 0: File, 1: Symlink, 2: Directory
}

type MessageType

type MessageType byte
const (
	FetchBlobType        MessageType = 0x01
	FetchBlobRespType    MessageType = 0x02
	FetchTreeType        MessageType = 0x03
	FetchTreeRespType    MessageType = 0x04
	FetchObjectType      MessageType = 0x05
	FetchObjectRespType  MessageType = 0x06
	NewBlobType          MessageType = 0x07
	NewTreeType          MessageType = 0x08
	NewObjectType        MessageType = 0x09
	FetchGitObjectType   MessageType = 0x0a
	GetStatType          MessageType = 0x0b
	GetStatRespType      MessageType = 0x0c
	VersionType          MessageType = 0x0d
	NotifyUseType        MessageType = 0x0e
	IdentityPutReqType   MessageType = 0x0f
	IdentityPutRespType  MessageType = 0x10
	IdentityGetReqType   MessageType = 0x11
	IdentityGetRespType  MessageType = 0x12
	MapResultsReqType    MessageType = 0x13
	MapResultsRespType   MessageType = 0x14
	PutInMapReqType      MessageType = 0x15
	PutInMapRespType     MessageType = 0x16
	FetchARIType         MessageType = 0x17
	FetchARIRespType     MessageType = 0x18
	InitDeeptreeReqType  MessageType = 0x19
	InitDeeptreeRespType MessageType = 0x1a
	CheckStatusType      MessageType = 0x1b
	CheckStatusRespType  MessageType = 0x1c
	FetchCASBlobType     MessageType = 0x1d
	FetchCASBlobRespType MessageType = 0x1e
)

type NewMapMessage

type NewMapMessage struct {
	From      entities.Hash
	To        entities.Hash
	LocalOnly bool
}

type NewObjectMessage

type NewObjectMessage struct {
	Hash entities.Hash
}

func ReadNewObjectMessage

func ReadNewObjectMessage(r io.Reader) (*NewObjectMessage, error)

type OverallPushStat

type OverallPushStat struct {
	BrokenLinks    int64
	MissingObjects int64
}

type PrefetchRequest

type PrefetchRequest struct {
	Blobs    []entities.Hash
	Objects  []entities.Hash
	Priority float64
}

type ProjectRefHash

type ProjectRefHash struct {
	Project string
	Ref     string
	Hash    string
}

type PushBuildMetricsReq

type PushBuildMetricsReq struct {
	AndroidTarget     string
	BuildGoal         string
	Status            string
	BuildDurationSecs float64
	HasNinjaRun       bool
	CacheHitRatio     float64
	CacheHitCount     uint32
	CacheMissCount    uint32
	Phases            map[string]float64
}

type PushGroupStat

type PushGroupStat struct {
	Requests int64
	Queued   int64
	Blocked  int64
	Pushing  int64
	Failed   int64
}

type PushStat

type PushStat struct {
	Request atomic.Int64
	Report  atomic.Int64
}

func (*PushStat) Diff

func (p *PushStat) Diff() string

type PutRefsReq

type PutRefsReq struct {
	Server   string
	Project  string
	Refs     []RefHash
	Blocking bool
}

type QueueStat

type QueueStat struct {
	Input   atomic.Int64
	Output  atomic.Int64
	Active  atomic.Int64
	Retries atomic.Int64
	Errors  atomic.Int64
}

func (*QueueStat) MarshalJSON

func (qs *QueueStat) MarshalJSON() ([]byte, error)

func (*QueueStat) UnmarshalJSON

func (qs *QueueStat) UnmarshalJSON(buf []byte) error

type RefHash

type RefHash struct {
	Ref  string
	Hash string
}

type RequestID

type RequestID uint32

type RequestObjectType

type RequestObjectType byte
const (
	TypeBlob    RequestObjectType = 1
	TypeTree    RequestObjectType = 2
	TypeObject  RequestObjectType = 3
	TypeARI     RequestObjectType = 4
	TypeCASBlob RequestObjectType = 5
)

func ParseRequestType

func ParseRequestType(t string) RequestObjectType

func (RequestObjectType) String

func (t RequestObjectType) String() string

type ResultType

type ResultType byte
const (
	ResultWait     ResultType = 0xff
	ResultSuccess  ResultType = 0x01
	ResultNotFound ResultType = 0x02
	ResultFailed   ResultType = 0x03
	ResultTimeout  ResultType = 0x04
)

func (ResultType) String

func (r ResultType) String() string

func (ResultType) ToError

func (r ResultType) ToError() error

type SearchRefsReq

type SearchRefsReq struct {
	Server    string
	Project   string
	RefPrefix string
	Limit     int
}

type UdsIdentityGetReq

type UdsIdentityGetReq struct {
	RequestID RequestID
	SHA1      entities.Hash
}

func ReadUdsIdentityGetReq

func ReadUdsIdentityGetReq(r io.Reader) (*UdsIdentityGetReq, error)

type UdsIdentityGetResp

type UdsIdentityGetResp struct {
	RequestID RequestID
	Result    ResultType
	SHA256    [32]byte
	Size      int64
	Type      byte
}

type UdsIdentityPutReq

type UdsIdentityPutReq struct {
	RequestID RequestID
	SHA1      entities.Hash
	SHA256    [32]byte
	Size      int64
	Type      byte
}

func ReadUdsIdentityPutReq

func ReadUdsIdentityPutReq(r io.Reader) (*UdsIdentityPutReq, error)

type UdsInitDeeptreeReq

type UdsInitDeeptreeReq struct {
	RequestID RequestID
	SHA1      entities.Hash
}

func ReadUdsInitDeeptreeReq

func ReadUdsInitDeeptreeReq(r io.Reader) (*UdsInitDeeptreeReq, error)

type UdsInitDeeptreeResp

type UdsInitDeeptreeResp struct {
	RequestID RequestID
	Result    ResultType
	SHA1      entities.Hash
}

type UdsMapResultsReq

type UdsMapResultsReq struct {
	RequestID RequestID
	SHA1      entities.Hash
}

func ReadUdsMapResultsReq

func ReadUdsMapResultsReq(r io.Reader) (*UdsMapResultsReq, error)

type UdsPutInMapReq

type UdsPutInMapReq struct {
	RequestID RequestID
	From      entities.Hash
	To        entities.Hash
	LocalOnly byte
}

func ReadUdsPutInMapReq

func ReadUdsPutInMapReq(r io.Reader) (*UdsPutInMapReq, error)

type WaitForRequest

type WaitForRequest struct {
	TimeoutSecs float64 // Zero means no timeout.
	Priority    float64
	Objects     []entities.Hash
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL