stats

package
v14.0.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2021 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bands

func Bands() []string

Bands returns the slice of bands which git uses to transport different kinds of data in a multiplexed way. See https://git-scm.com/docs/protocol-capabilities/2.24.0#_side_band_side_band_64k for more information about the different bands.

func GetPackfiles

func GetPackfiles(repoPath string) ([]os.FileInfo, error)

GetPackfiles returns the FileInfo of packfiles inside a repository.

func HasBitmap

func HasBitmap(repoPath string) (bool, error)

HasBitmap returns whether or not the repository contains an object bitmap.

func LogObjectsInfo

func LogObjectsInfo(ctx context.Context, gitCmdFactory git.CommandFactory, repo repository.GitRepo)

LogObjectsInfo read statistics of the git repo objects and logs it under 'count-objects' key as structured entry.

func LooseObjects

func LooseObjects(ctx context.Context, gitCmdFactory git.CommandFactory, repository repository.GitRepo) (int64, error)

LooseObjects returns the number of loose objects that are not in a packfile.

func PackfilesCount

func PackfilesCount(repoPath string) (int, error)

PackfilesCount returns the number of packfiles a repository has.

func UnpackedObjects

func UnpackedObjects(repoPath string) (int64, error)

UnpackedObjects returns the number of loose objects that have a timestamp later than the newest packfile.

Types

type Clone

type Clone struct {
	URL         string
	Interactive bool
	User        string
	Password    string

	Get
	Post
	// contains filtered or unexported fields
}

func (*Clone) Perform

func (cl *Clone) Perform(ctx context.Context) error

Perform does a Git HTTP clone, discarding cloned data to /dev/null.

func (*Clone) RefsWanted

func (cl *Clone) RefsWanted() int

type Get

type Get struct {
	ReferenceDiscovery
	// contains filtered or unexported fields
}

func (*Get) FirstGitPacket

func (g *Get) FirstGitPacket() time.Duration

func (*Get) HTTPStatus

func (g *Get) HTTPStatus() int

func (*Get) ResponseBody

func (g *Get) ResponseBody() time.Duration

func (*Get) ResponseHeader

func (g *Get) ResponseHeader() time.Duration

type PackfileNegotiation

type PackfileNegotiation struct {
	// Total size of all pktlines' data
	PayloadSize int64
	// Total number of packets
	Packets int
	// Capabilities announced by the client
	Caps []string
	// Wants is the number of objects the client announced it wants
	Wants int
	// Haves is the number of objects the client announced it has
	Haves int
	// Shallows is the number of shallow boundaries announced by the client
	Shallows int
	// Deepen-filter. One of "deepen <depth>", "deepen-since <timestamp>", "deepen-not <ref>".
	Deepen string
	// Filter-spec specified by the client.
	Filter string
}

func ParsePackfileNegotiation

func ParsePackfileNegotiation(body io.Reader) (PackfileNegotiation, error)

func (*PackfileNegotiation) Parse

func (n *PackfileNegotiation) Parse(body io.Reader) error

Parse parses a packfile negotiation. It expects the following format:

want <OID> <capabilities\n [want <OID>...] [shallow <OID>] [deepen <depth>|deepen-since <timestamp>|deepen-not <ref>] [filter <filter-spec>] flush have <OID> flush|done

func (*PackfileNegotiation) UpdateMetrics

func (n *PackfileNegotiation) UpdateMetrics(metrics *prometheus.CounterVec)

UpdateMetrics updates Prometheus counters with features that have been used during a packfile negotiation.

type Post

type Post struct {
	// contains filtered or unexported fields
}

func (*Post) BandFirstPacket

func (p *Post) BandFirstPacket(b string) time.Duration

func (*Post) BandPackets

func (p *Post) BandPackets(b string) int

func (*Post) BandPayloadSize

func (p *Post) BandPayloadSize(b string) int64

func (*Post) HTTPStatus

func (p *Post) HTTPStatus() int

func (*Post) LargestPacketSize

func (p *Post) LargestPacketSize() int

func (*Post) NAK

func (p *Post) NAK() time.Duration

func (*Post) Packets

func (p *Post) Packets() int

func (*Post) ResponseBody

func (p *Post) ResponseBody() time.Duration

func (*Post) ResponseHeader

func (p *Post) ResponseHeader() time.Duration

type Reference

type Reference struct {
	// Oid is the object ID the reference points to
	Oid string
	// Name of the reference. The name will be suffixed with ^{} in case
	// the reference is the peeled commit.
	Name string
}

Reference as used by the reference discovery protocol

type ReferenceDiscovery

type ReferenceDiscovery struct {
	// FirstPacket tracks the time when the first pktline was received
	FirstPacket time.Time
	// LastPacket tracks the time when the last pktline was received
	LastPacket time.Time
	// PayloadSize tracks the size of all pktlines' data
	PayloadSize int64
	// Packets tracks the total number of packets consumed
	Packets int
	// Refs contains all announced references
	Refs []Reference
	// Caps contains all supported capabilities
	Caps []string
}

ReferenceDiscovery contains information about a reference discovery session.

func ParseReferenceDiscovery

func ParseReferenceDiscovery(body io.Reader) (ReferenceDiscovery, error)

ParseReferenceDiscovery parses a client's reference discovery stream and returns either information about the reference discovery or an error in case it couldn't make sense of the client's request.

func (*ReferenceDiscovery) Parse

func (d *ReferenceDiscovery) Parse(body io.Reader) error

Parse parses a client's reference discovery stream into the given ReferenceDiscovery struct or returns an error in case it couldn't make sense of the client's request.

Expected protocol: - "# service=git-upload-pack\n" - FLUSH - "<OID> <ref>\x00<capabilities>\n" - "<OID> <ref>\n" - ... - FLUSH

Jump to

Keyboard shortcuts

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