storev1

package module
v0.0.0-...-2d438d4 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2024 License: MIT Imports: 17 Imported by: 3

README

store-go

This directory contains generated golang bindings, both for the tvix-store data models, as well as the gRPC bindings.

They are generated with mg run //tvix:store-go:regenerate. These files end with .pb.go, and are ensured to be up to date by Ci check.

Additionally, code useful when interacting with these data structures (ending just with .go) is provided.

Documentation

Index

Constants

View Source
const (
	PathInfoService_Get_FullMethodName          = "/tvix.store.v1.PathInfoService/Get"
	PathInfoService_Put_FullMethodName          = "/tvix.store.v1.PathInfoService/Put"
	PathInfoService_CalculateNAR_FullMethodName = "/tvix.store.v1.PathInfoService/CalculateNAR"
	PathInfoService_List_FullMethodName         = "/tvix.store.v1.PathInfoService/List"
)

Variables

View Source
var (
	NARInfo_CA_Hash_name = map[int32]string{
		0: "NAR_SHA256",
		1: "NAR_SHA1",
		2: "NAR_SHA512",
		3: "NAR_MD5",
		4: "TEXT_SHA256",
		5: "FLAT_SHA1",
		6: "FLAT_MD5",
		7: "FLAT_SHA256",
		8: "FLAT_SHA512",
	}
	NARInfo_CA_Hash_value = map[string]int32{
		"NAR_SHA256":  0,
		"NAR_SHA1":    1,
		"NAR_SHA512":  2,
		"NAR_MD5":     3,
		"TEXT_SHA256": 4,
		"FLAT_SHA1":   5,
		"FLAT_MD5":    6,
		"FLAT_SHA256": 7,
		"FLAT_SHA512": 8,
	}
)

Enum value maps for NARInfo_CA_Hash.

View Source
var File_tvix_store_protos_pathinfo_proto protoreflect.FileDescriptor
View Source
var File_tvix_store_protos_rpc_pathinfo_proto protoreflect.FileDescriptor
View Source
var PathInfoService_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "tvix.store.v1.PathInfoService",
	HandlerType: (*PathInfoServiceServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "Get",
			Handler:    _PathInfoService_Get_Handler,
		},
		{
			MethodName: "Put",
			Handler:    _PathInfoService_Put_Handler,
		},
		{
			MethodName: "CalculateNAR",
			Handler:    _PathInfoService_CalculateNAR_Handler,
		},
	},
	Streams: []grpc.StreamDesc{
		{
			StreamName:    "List",
			Handler:       _PathInfoService_List_Handler,
			ServerStreams: true,
		},
	},
	Metadata: "tvix/store/protos/rpc_pathinfo.proto",
}

PathInfoService_ServiceDesc is the grpc.ServiceDesc for PathInfoService service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)

Functions

func Export

func Export(
	w io.Writer,
	rootNode *castorev1pb.Node,
	directoryLookupFn DirectoryLookupFn,
	blobLookupFn BlobLookupFn,
) error

Export will traverse a given root node, and write the contents in NAR format to the passed Writer. It uses directoryLookupFn and blobLookupFn to resolve references.

func RegisterPathInfoServiceServer

func RegisterPathInfoServiceServer(s grpc.ServiceRegistrar, srv PathInfoServiceServer)

Types

type BlobLookupFn

type BlobLookupFn func([]byte) (io.ReadCloser, error)

type CalculateNARResponse

type CalculateNARResponse struct {

	// This size of the NAR file, in bytes.
	NarSize uint64 `protobuf:"varint,1,opt,name=nar_size,json=narSize,proto3" json:"nar_size,omitempty"`
	// The sha256 of the NAR file representation.
	NarSha256 []byte `protobuf:"bytes,2,opt,name=nar_sha256,json=narSha256,proto3" json:"nar_sha256,omitempty"`
	// contains filtered or unexported fields
}

CalculateNARResponse is the response returned by the CalculateNAR request.

It contains the size of the NAR representation (in bytes), and the sha56 digest.

func (*CalculateNARResponse) Descriptor deprecated

func (*CalculateNARResponse) Descriptor() ([]byte, []int)

Deprecated: Use CalculateNARResponse.ProtoReflect.Descriptor instead.

func (*CalculateNARResponse) GetNarSha256

func (x *CalculateNARResponse) GetNarSha256() []byte

func (*CalculateNARResponse) GetNarSize

func (x *CalculateNARResponse) GetNarSize() uint64

func (*CalculateNARResponse) ProtoMessage

func (*CalculateNARResponse) ProtoMessage()

func (*CalculateNARResponse) ProtoReflect

func (x *CalculateNARResponse) ProtoReflect() protoreflect.Message

func (*CalculateNARResponse) Reset

func (x *CalculateNARResponse) Reset()

func (*CalculateNARResponse) String

func (x *CalculateNARResponse) String() string

type DirectoryLookupFn

type DirectoryLookupFn func([]byte) (*castorev1pb.Directory, error)

type GetPathInfoRequest

type GetPathInfoRequest struct {

	// Types that are assignable to ByWhat:
	//
	//	*GetPathInfoRequest_ByOutputHash
	ByWhat isGetPathInfoRequest_ByWhat `protobuf_oneof:"by_what"`
	// contains filtered or unexported fields
}

The parameters that can be used to lookup a (single) PathInfo object. Currently, only a lookup by output hash is supported.

func (*GetPathInfoRequest) Descriptor deprecated

func (*GetPathInfoRequest) Descriptor() ([]byte, []int)

Deprecated: Use GetPathInfoRequest.ProtoReflect.Descriptor instead.

func (*GetPathInfoRequest) GetByOutputHash

func (x *GetPathInfoRequest) GetByOutputHash() []byte

func (*GetPathInfoRequest) GetByWhat

func (m *GetPathInfoRequest) GetByWhat() isGetPathInfoRequest_ByWhat

func (*GetPathInfoRequest) ProtoMessage

func (*GetPathInfoRequest) ProtoMessage()

func (*GetPathInfoRequest) ProtoReflect

func (x *GetPathInfoRequest) ProtoReflect() protoreflect.Message

func (*GetPathInfoRequest) Reset

func (x *GetPathInfoRequest) Reset()

func (*GetPathInfoRequest) String

func (x *GetPathInfoRequest) String() string

type GetPathInfoRequest_ByOutputHash

type GetPathInfoRequest_ByOutputHash struct {
	// The output hash of a nix path (20 bytes).
	// This is the nixbase32-decoded portion of a Nix output path, so to substitute
	// /nix/store/xm35nga2g20mz5sm5l6n8v3bdm86yj83-cowsay-3.04
	// this field would contain nixbase32dec("xm35nga2g20mz5sm5l6n8v3bdm86yj83").
	ByOutputHash []byte `protobuf:"bytes,1,opt,name=by_output_hash,json=byOutputHash,proto3,oneof"`
}

type ListPathInfoRequest

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

The parameters that can be used to lookup (multiple) PathInfo objects. Currently no filtering is possible, all objects are returned.

func (*ListPathInfoRequest) Descriptor deprecated

func (*ListPathInfoRequest) Descriptor() ([]byte, []int)

Deprecated: Use ListPathInfoRequest.ProtoReflect.Descriptor instead.

func (*ListPathInfoRequest) ProtoMessage

func (*ListPathInfoRequest) ProtoMessage()

func (*ListPathInfoRequest) ProtoReflect

func (x *ListPathInfoRequest) ProtoReflect() protoreflect.Message

func (*ListPathInfoRequest) Reset

func (x *ListPathInfoRequest) Reset()

func (*ListPathInfoRequest) String

func (x *ListPathInfoRequest) String() string

type NARInfo

type NARInfo struct {

	// This size of the NAR file, in bytes.
	NarSize uint64 `protobuf:"varint,1,opt,name=nar_size,json=narSize,proto3" json:"nar_size,omitempty"`
	// The sha256 of the NAR file representation.
	NarSha256 []byte `protobuf:"bytes,2,opt,name=nar_sha256,json=narSha256,proto3" json:"nar_sha256,omitempty"`
	// The signatures in a .narinfo file.
	Signatures []*NARInfo_Signature `protobuf:"bytes,3,rep,name=signatures,proto3" json:"signatures,omitempty"`
	// A list of references. To validate .narinfo signatures, a fingerprint needs
	// to be constructed.
	// This fingerprint doesn't just contain the hashes of the output paths of all
	// references (like PathInfo.references), but their whole (base)names, so we
	// need to keep them somewhere.
	ReferenceNames []string `protobuf:"bytes,4,rep,name=reference_names,json=referenceNames,proto3" json:"reference_names,omitempty"`
	// The StorePath of the .drv file producing this output.
	// The .drv suffix is omitted in its `name` field.
	Deriver *StorePath `protobuf:"bytes,5,opt,name=deriver,proto3" json:"deriver,omitempty"`
	// The CA field in the .narinfo.
	// Its textual representations seen in the wild are one of the following:
	//   - `fixed:r:sha256:1gcky5hlf5vqfzpyhihydmm54grhc94mcs8w7xr8613qsqb1v2j6`
	//     fixed-output derivations using "recursive" `outputHashMode`.
	//   - `fixed:sha256:19xqkh72crbcba7flwxyi3n293vav6d7qkzkh2v4zfyi4iia8vj8
	//     fixed-output derivations using "flat" `outputHashMode`
	//   - `text:sha256:19xqkh72crbcba7flwxyi3n293vav6d7qkzkh2v4zfyi4iia8vj8`
	//     Text hashing, used for uploaded .drv files and outputs produced by
	//     builtins.toFile.
	//
	// Semantically, they can be split into the following components:
	//   - "content address prefix". Currently, "fixed" and "text" are supported.
	//   - "hash mode". Currently, "flat" and "recursive" are supported.
	//   - "hash type". The underlying hash function used.
	//     Currently, sha1, md5, sha256, sha512.
	//   - "digest". The digest itself.
	//
	// There are some restrictions on the possible combinations.
	// For example, `text` and `fixed:recursive` always imply sha256.
	//
	// We use an enum to encode the possible combinations, and optimize for the
	// common case, `fixed:recursive`, identified as `NAR_SHA256`.
	Ca *NARInfo_CA `protobuf:"bytes,6,opt,name=ca,proto3" json:"ca,omitempty"`
	// contains filtered or unexported fields
}

Nix C++ uses NAR (Nix Archive) as a format to transfer store paths, and stores metadata and signatures in NARInfo files. Store all these attributes in a separate message.

This is useful to render .narinfo files to clients, or to preserve/validate these signatures. As verifying these signatures requires the whole NAR file to be synthesized, moving to another signature scheme is desired. Even then, it still makes sense to hold this data, for old clients.

func (*NARInfo) Descriptor deprecated

func (*NARInfo) Descriptor() ([]byte, []int)

Deprecated: Use NARInfo.ProtoReflect.Descriptor instead.

func (*NARInfo) GetCa

func (x *NARInfo) GetCa() *NARInfo_CA

func (*NARInfo) GetDeriver

func (x *NARInfo) GetDeriver() *StorePath

func (*NARInfo) GetNarSha256

func (x *NARInfo) GetNarSha256() []byte

func (*NARInfo) GetNarSize

func (x *NARInfo) GetNarSize() uint64

func (*NARInfo) GetReferenceNames

func (x *NARInfo) GetReferenceNames() []string

func (*NARInfo) GetSignatures

func (x *NARInfo) GetSignatures() []*NARInfo_Signature

func (*NARInfo) ProtoMessage

func (*NARInfo) ProtoMessage()

func (*NARInfo) ProtoReflect

func (x *NARInfo) ProtoReflect() protoreflect.Message

func (*NARInfo) Reset

func (x *NARInfo) Reset()

func (*NARInfo) String

func (x *NARInfo) String() string

type NARInfo_CA

type NARInfo_CA struct {

	// The hashing type used.
	Type NARInfo_CA_Hash `protobuf:"varint,1,opt,name=type,proto3,enum=tvix.store.v1.NARInfo_CA_Hash" json:"type,omitempty"`
	// The digest, in raw bytes.
	Digest []byte `protobuf:"bytes,2,opt,name=digest,proto3" json:"digest,omitempty"`
	// contains filtered or unexported fields
}

func (*NARInfo_CA) Descriptor deprecated

func (*NARInfo_CA) Descriptor() ([]byte, []int)

Deprecated: Use NARInfo_CA.ProtoReflect.Descriptor instead.

func (*NARInfo_CA) GetDigest

func (x *NARInfo_CA) GetDigest() []byte

func (*NARInfo_CA) GetType

func (x *NARInfo_CA) GetType() NARInfo_CA_Hash

func (*NARInfo_CA) ProtoMessage

func (*NARInfo_CA) ProtoMessage()

func (*NARInfo_CA) ProtoReflect

func (x *NARInfo_CA) ProtoReflect() protoreflect.Message

func (*NARInfo_CA) Reset

func (x *NARInfo_CA) Reset()

func (*NARInfo_CA) String

func (x *NARInfo_CA) String() string

type NARInfo_CA_Hash

type NARInfo_CA_Hash int32
const (
	// produced when uploading fixed-output store paths using NAR-based
	// hashing (`outputHashMode = "recursive"`).
	NARInfo_CA_NAR_SHA256 NARInfo_CA_Hash = 0
	NARInfo_CA_NAR_SHA1   NARInfo_CA_Hash = 1
	NARInfo_CA_NAR_SHA512 NARInfo_CA_Hash = 2
	NARInfo_CA_NAR_MD5    NARInfo_CA_Hash = 3
	// Produced when uploading .drv files or outputs produced by
	// builtins.toFile.
	// Produces equivalent digests as FLAT_SHA256, but is a separate
	// hashing type in Nix, affecting output path calculation.
	NARInfo_CA_TEXT_SHA256 NARInfo_CA_Hash = 4
	// Produced when using fixed-output derivations with
	// `outputHashMode = "flat"`.
	NARInfo_CA_FLAT_SHA1   NARInfo_CA_Hash = 5
	NARInfo_CA_FLAT_MD5    NARInfo_CA_Hash = 6
	NARInfo_CA_FLAT_SHA256 NARInfo_CA_Hash = 7
	NARInfo_CA_FLAT_SHA512 NARInfo_CA_Hash = 8
)

func (NARInfo_CA_Hash) Descriptor

func (NARInfo_CA_Hash) Enum

func (x NARInfo_CA_Hash) Enum() *NARInfo_CA_Hash

func (NARInfo_CA_Hash) EnumDescriptor deprecated

func (NARInfo_CA_Hash) EnumDescriptor() ([]byte, []int)

Deprecated: Use NARInfo_CA_Hash.Descriptor instead.

func (NARInfo_CA_Hash) Number

func (NARInfo_CA_Hash) String

func (x NARInfo_CA_Hash) String() string

func (NARInfo_CA_Hash) Type

type NARInfo_Signature

type NARInfo_Signature struct {
	Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	Data []byte `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"`
	// contains filtered or unexported fields
}

This represents a (parsed) signature line in a .narinfo file.

func (*NARInfo_Signature) Descriptor deprecated

func (*NARInfo_Signature) Descriptor() ([]byte, []int)

Deprecated: Use NARInfo_Signature.ProtoReflect.Descriptor instead.

func (*NARInfo_Signature) GetData

func (x *NARInfo_Signature) GetData() []byte

func (*NARInfo_Signature) GetName

func (x *NARInfo_Signature) GetName() string

func (*NARInfo_Signature) ProtoMessage

func (*NARInfo_Signature) ProtoMessage()

func (*NARInfo_Signature) ProtoReflect

func (x *NARInfo_Signature) ProtoReflect() protoreflect.Message

func (*NARInfo_Signature) Reset

func (x *NARInfo_Signature) Reset()

func (*NARInfo_Signature) String

func (x *NARInfo_Signature) String() string

type PathInfo

type PathInfo struct {

	// The path can be a directory, file or symlink.
	Node *castore_go.Node `protobuf:"bytes,1,opt,name=node,proto3" json:"node,omitempty"`
	// List of references (output path hashes)
	// This really is the raw *bytes*, after decoding nixbase32, and not a
	// base32-encoded string.
	References [][]byte `protobuf:"bytes,2,rep,name=references,proto3" json:"references,omitempty"`
	// see below.
	Narinfo *NARInfo `protobuf:"bytes,3,opt,name=narinfo,proto3" json:"narinfo,omitempty"`
	// contains filtered or unexported fields
}

PathInfo shows information about a Nix Store Path. That's a single element inside /nix/store.

func (*PathInfo) Descriptor deprecated

func (*PathInfo) Descriptor() ([]byte, []int)

Deprecated: Use PathInfo.ProtoReflect.Descriptor instead.

func (*PathInfo) GetNarinfo

func (x *PathInfo) GetNarinfo() *NARInfo

func (*PathInfo) GetNode

func (x *PathInfo) GetNode() *castore_go.Node

func (*PathInfo) GetReferences

func (x *PathInfo) GetReferences() [][]byte

func (*PathInfo) ProtoMessage

func (*PathInfo) ProtoMessage()

func (*PathInfo) ProtoReflect

func (x *PathInfo) ProtoReflect() protoreflect.Message

func (*PathInfo) Reset

func (x *PathInfo) Reset()

func (*PathInfo) String

func (x *PathInfo) String() string

func (*PathInfo) Validate

func (p *PathInfo) Validate() (*storepath.StorePath, error)

Validate performs some checks on the PathInfo struct, returning either the StorePath of the root node, or an error.

type PathInfoServiceClient

type PathInfoServiceClient interface {
	// Return a PathInfo message matching the criteria specified in the
	// GetPathInfoRequest message.
	Get(ctx context.Context, in *GetPathInfoRequest, opts ...grpc.CallOption) (*PathInfo, error)
	// Upload a PathInfo object to the remote end. It MUST not return until the
	// PathInfo object has been written on the the remote end.
	//
	// The remote end MAY check if a potential DirectoryNode has already been
	// uploaded.
	//
	// Uploading clients SHOULD obviously not steer other machines to try to
	// substitute before from the remote end before having finished uploading
	// PathInfo, Directories and Blobs.
	// The returned PathInfo object MAY contain additional narinfo signatures, but
	// is otherwise left untouched.
	Put(ctx context.Context, in *PathInfo, opts ...grpc.CallOption) (*PathInfo, error)
	// Calculate the NAR representation of the contents specified by the
	// root_node. The calculation SHOULD be cached server-side for subsequent
	// requests.
	//
	// All references (to blobs or Directory messages) MUST already exist in the
	// store.
	//
	// The method can be used to produce a Nix fixed-output path, which contains
	// the (compressed) sha256 of the NAR content representation in the root_node
	// name (suffixed with the name).
	//
	// It can also be used to calculate arbitrary NAR hashes of output paths, in
	// case a legacy Nix Binary Cache frontend is provided.
	CalculateNAR(ctx context.Context, in *castore_go.Node, opts ...grpc.CallOption) (*CalculateNARResponse, error)
	// Return a stream of PathInfo messages matching the criteria specified in
	// ListPathInfoRequest.
	List(ctx context.Context, in *ListPathInfoRequest, opts ...grpc.CallOption) (PathInfoService_ListClient, error)
}

PathInfoServiceClient is the client API for PathInfoService service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.

func NewPathInfoServiceClient

func NewPathInfoServiceClient(cc grpc.ClientConnInterface) PathInfoServiceClient

type PathInfoServiceServer

type PathInfoServiceServer interface {
	// Return a PathInfo message matching the criteria specified in the
	// GetPathInfoRequest message.
	Get(context.Context, *GetPathInfoRequest) (*PathInfo, error)
	// Upload a PathInfo object to the remote end. It MUST not return until the
	// PathInfo object has been written on the the remote end.
	//
	// The remote end MAY check if a potential DirectoryNode has already been
	// uploaded.
	//
	// Uploading clients SHOULD obviously not steer other machines to try to
	// substitute before from the remote end before having finished uploading
	// PathInfo, Directories and Blobs.
	// The returned PathInfo object MAY contain additional narinfo signatures, but
	// is otherwise left untouched.
	Put(context.Context, *PathInfo) (*PathInfo, error)
	// Calculate the NAR representation of the contents specified by the
	// root_node. The calculation SHOULD be cached server-side for subsequent
	// requests.
	//
	// All references (to blobs or Directory messages) MUST already exist in the
	// store.
	//
	// The method can be used to produce a Nix fixed-output path, which contains
	// the (compressed) sha256 of the NAR content representation in the root_node
	// name (suffixed with the name).
	//
	// It can also be used to calculate arbitrary NAR hashes of output paths, in
	// case a legacy Nix Binary Cache frontend is provided.
	CalculateNAR(context.Context, *castore_go.Node) (*CalculateNARResponse, error)
	// Return a stream of PathInfo messages matching the criteria specified in
	// ListPathInfoRequest.
	List(*ListPathInfoRequest, PathInfoService_ListServer) error
	// contains filtered or unexported methods
}

PathInfoServiceServer is the server API for PathInfoService service. All implementations must embed UnimplementedPathInfoServiceServer for forward compatibility

type PathInfoService_ListClient

type PathInfoService_ListClient interface {
	Recv() (*PathInfo, error)
	grpc.ClientStream
}

type PathInfoService_ListServer

type PathInfoService_ListServer interface {
	Send(*PathInfo) error
	grpc.ServerStream
}

type StorePath

type StorePath struct {

	// The string after digest and `-`.
	Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	// The digest (20 bytes).
	Digest []byte `protobuf:"bytes,2,opt,name=digest,proto3" json:"digest,omitempty"`
	// contains filtered or unexported fields
}

Represents a path in the Nix store (a direct child of STORE_DIR). It is commonly formatted by a nixbase32-encoding the digest, and concatenating the name, separated by a `-`.

func (*StorePath) Descriptor deprecated

func (*StorePath) Descriptor() ([]byte, []int)

Deprecated: Use StorePath.ProtoReflect.Descriptor instead.

func (*StorePath) GetDigest

func (x *StorePath) GetDigest() []byte

func (*StorePath) GetName

func (x *StorePath) GetName() string

func (*StorePath) ProtoMessage

func (*StorePath) ProtoMessage()

func (*StorePath) ProtoReflect

func (x *StorePath) ProtoReflect() protoreflect.Message

func (*StorePath) Reset

func (x *StorePath) Reset()

func (*StorePath) String

func (x *StorePath) String() string

type UnimplementedPathInfoServiceServer

type UnimplementedPathInfoServiceServer struct {
}

UnimplementedPathInfoServiceServer must be embedded to have forward compatible implementations.

func (UnimplementedPathInfoServiceServer) CalculateNAR

func (UnimplementedPathInfoServiceServer) Get

func (UnimplementedPathInfoServiceServer) List

func (UnimplementedPathInfoServiceServer) Put

type UnsafePathInfoServiceServer

type UnsafePathInfoServiceServer interface {
	// contains filtered or unexported methods
}

UnsafePathInfoServiceServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to PathInfoServiceServer will result in compilation errors.

Jump to

Keyboard shortcuts

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