Documentation
¶
Overview ¶
Package gitsync provides the public orchestration API for git-sync.
The public surface is intentionally narrower than the internal engine: callers express sync intent through typed probe, plan, and sync requests, while relay selection, batching, and fallback strategy remain internal.
The package is designed for embedders such as queue workers. Callers can:
- inject an HTTP client for transport, OTEL, proxy, TLS, and timeout control
- inject an auth provider that resolves source and target credentials
- inspect structured results for per-ref outcomes and aggregate counters
Current advanced engine tuning such as batch sizing, max pack thresholds, and heap measurement remains outside this stable public surface.
Index ¶
- type Action
- type AuthProvider
- type BatchSummary
- type Client
- func (c *Client) Plan(ctx context.Context, req PlanRequest) (PlanResult, error)
- func (c *Client) Probe(ctx context.Context, req ProbeRequest) (ProbeResult, error)
- func (c *Client) Replicate(ctx context.Context, req SyncRequest) (SyncResult, error)
- func (c *Client) Sync(ctx context.Context, req SyncRequest) (SyncResult, error)
- type Endpoint
- type EndpointAuth
- type EndpointRole
- type ExecutionSummary
- type Measurement
- type OperationMode
- type Options
- type PlanRequest
- type PlanResult
- type ProbeRequest
- type ProbeResult
- type ProtocolMode
- type RefInfo
- type RefKind
- type RefMapping
- type RefPlan
- type RefResult
- type RefScope
- type ServiceStats
- type StaticAuthProvider
- type Stats
- type SyncCounts
- type SyncPolicy
- type SyncRequest
- type SyncResult
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Action ¶
type Action = internalbridge.Action
const ( ActionCreate Action = internalbridge.ActionCreate ActionUpdate Action = internalbridge.ActionUpdate ActionDelete Action = internalbridge.ActionDelete ActionSkip Action = internalbridge.ActionSkip ActionBlock Action = internalbridge.ActionBlock )
type AuthProvider ¶
type AuthProvider interface {
AuthFor(ctx context.Context, endpoint Endpoint, role EndpointRole) (EndpointAuth, error)
}
AuthProvider resolves auth for a request endpoint.
type BatchSummary ¶
type BatchSummary = internalbridge.BatchSummary
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client provides the public orchestration API for git-sync.
func (*Client) Plan ¶
func (c *Client) Plan(ctx context.Context, req PlanRequest) (PlanResult, error)
Plan computes ref actions without pushing.
func (*Client) Probe ¶
func (c *Client) Probe(ctx context.Context, req ProbeRequest) (ProbeResult, error)
Probe inspects a source remote and optional target remote.
func (*Client) Replicate ¶
func (c *Client) Replicate(ctx context.Context, req SyncRequest) (SyncResult, error)
Replicate executes source-authoritative relay-only replication between two remotes.
func (*Client) Sync ¶
func (c *Client) Sync(ctx context.Context, req SyncRequest) (SyncResult, error)
Sync executes a sync between two remotes.
Example ¶
client := gitsync.New(gitsync.Options{
HTTPClient: &http.Client{},
Auth: gitsync.StaticAuthProvider{
Source: gitsync.EndpointAuth{Token: "source-token"},
Target: gitsync.EndpointAuth{Token: "target-token"},
},
})
if _, err := client.Sync(context.Background(), gitsync.SyncRequest{
Source: gitsync.Endpoint{URL: "https://github.example/source/repo.git"},
Target: gitsync.Endpoint{URL: "https://git.example/target/repo.git"},
Scope: gitsync.RefScope{Branches: []string{"main"}},
Policy: gitsync.SyncPolicy{
IncludeTags: true,
Protocol: gitsync.ProtocolAuto,
},
}); err != nil {
return // network error expected in example environment
}
type Endpoint ¶
type Endpoint struct {
URL string `json:"url"`
// FollowInfoRefsRedirect, when true, rewrites this endpoint's
// effective host to the final URL returned by /info/refs after
// HTTP redirects. Subsequent git RPCs (git-upload-pack,
// git-receive-pack) then target the redirected host directly.
// Matches vanilla git's smart-HTTP behaviour for discovery-aware
// servers that 307 /info/refs to a hosting replica.
FollowInfoRefsRedirect bool `json:"followInfoRefsRedirect,omitempty"`
}
Endpoint identifies a remote Git endpoint.
type EndpointAuth ¶
type EndpointAuth struct {
Username string `json:"username"`
Token string `json:"token"`
BearerToken string `json:"bearerToken"`
SkipTLSVerify bool `json:"skipTlsVerify"`
}
EndpointAuth carries explicit per-request auth and TLS settings. It is resolved through an AuthProvider rather than embedded in Endpoint so endpoint identity does not also become the public auth-precedence boundary.
type EndpointRole ¶
type EndpointRole string
EndpointRole identifies whether auth is being resolved for the source or target.
const ( SourceRole EndpointRole = "source" TargetRole EndpointRole = "target" )
type ExecutionSummary ¶
type ExecutionSummary = internalbridge.ExecutionSummary
type Measurement ¶
type Measurement = internalbridge.Measurement
type OperationMode ¶
type OperationMode string
OperationMode controls high-level sync semantics.
const ( ModeSync OperationMode = "sync" ModeReplicate OperationMode = "replicate" )
type Options ¶
type Options struct {
HTTPClient *http.Client
Auth AuthProvider
}
Options configures a Client. It is intentionally small in the first public cut.
type PlanRequest ¶
type PlanRequest struct {
Source Endpoint `json:"source"`
Target Endpoint `json:"target"`
Scope RefScope `json:"scope"`
Policy SyncPolicy `json:"policy"`
CollectStats bool `json:"collectStats"`
}
PlanRequest computes ref actions without pushing.
func (PlanRequest) Validate ¶
func (r PlanRequest) Validate() error
type PlanResult ¶
type PlanResult = internalbridge.PlanResult
type ProbeRequest ¶
type ProbeRequest struct {
Source Endpoint `json:"source"`
Target *Endpoint `json:"target"`
IncludeTags bool `json:"includeTags"`
Protocol ProtocolMode `json:"protocol"`
CollectStats bool `json:"collectStats"`
}
ProbeRequest inspects source refs and optional target capabilities.
func (ProbeRequest) Validate ¶
func (r ProbeRequest) Validate() error
type ProbeResult ¶
type ProbeResult = internalbridge.ProbeResult
type ProtocolMode ¶
type ProtocolMode string
ProtocolMode controls source-side protocol negotiation.
const ( ProtocolAuto ProtocolMode = "auto" ProtocolV1 ProtocolMode = "v1" ProtocolV2 ProtocolMode = "v2" )
type RefInfo ¶
type RefInfo = internalbridge.RefInfo
type RefKind ¶
type RefKind = internalbridge.RefKind
const ( RefKindBranch RefKind = internalbridge.RefKindBranch RefKindTag RefKind = internalbridge.RefKindTag )
type RefMapping ¶
RefMapping is an explicit source-to-target ref mapping.
type RefPlan ¶
type RefPlan = internalbridge.RefPlan
type RefResult ¶
type RefResult = internalbridge.RefResult
type RefScope ¶
type RefScope struct {
Branches []string `json:"branches"`
Mappings []RefMapping `json:"mappings"`
}
RefScope constrains which refs a request manages.
type ServiceStats ¶
type ServiceStats = internalbridge.ServiceStats
type StaticAuthProvider ¶
type StaticAuthProvider struct {
Source EndpointAuth `json:"source"`
Target EndpointAuth `json:"target"`
}
StaticAuthProvider returns fixed source and target auth values.
func (StaticAuthProvider) AuthFor ¶
func (p StaticAuthProvider) AuthFor(_ context.Context, _ Endpoint, role EndpointRole) (EndpointAuth, error)
AuthFor implements AuthProvider.
type Stats ¶
type Stats = internalbridge.Stats
type SyncCounts ¶
type SyncCounts = internalbridge.SyncCounts
type SyncPolicy ¶
type SyncPolicy struct {
Mode OperationMode `json:"mode"`
IncludeTags bool `json:"includeTags"`
Force bool `json:"force"`
Prune bool `json:"prune"`
Protocol ProtocolMode `json:"protocol"`
}
SyncPolicy controls high-level sync behavior.
type SyncRequest ¶
type SyncRequest struct {
Source Endpoint `json:"source"`
Target Endpoint `json:"target"`
Scope RefScope `json:"scope"`
Policy SyncPolicy `json:"policy"`
CollectStats bool `json:"collectStats"`
}
SyncRequest executes a sync between two remotes.
func (SyncRequest) Validate ¶
func (r SyncRequest) Validate() error
type SyncResult ¶
type SyncResult = internalbridge.SyncResult
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
git-sync
command
|
|
|
git-sync-bench
command
|
|
|
internal
|
|
|
convert
Package convert provides shared type conversions between planner and gitproto types.
|
Package convert provides shared type conversions between planner and gitproto types. |
|
strategy/bootstrap
Package bootstrap implements the bootstrap relay strategy for git-sync.
|
Package bootstrap implements the bootstrap relay strategy for git-sync. |
|
strategy/incremental
Package incremental implements the incremental relay strategy for git-sync.
|
Package incremental implements the incremental relay strategy for git-sync. |
|
strategy/materialized
Package materialized implements the materialized fallback push strategy.
|
Package materialized implements the materialized fallback push strategy. |
|
strategy/replicate
Package replicate implements relay-only source-authoritative replication.
|
Package replicate implements relay-only source-authoritative replication. |
|
syncer
Package syncer provides the top-level orchestration for git-sync.
|
Package syncer provides the top-level orchestration for git-sync. |
|
Package unstable exposes advanced git-sync controls and commands that are intentionally outside the stable gitsync surface.
|
Package unstable exposes advanced git-sync controls and commands that are intentionally outside the stable gitsync surface. |
