storev1

package module
v0.0.0-...-ff5d173 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2023 License: MIT Imports: 17 Imported by: 1

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-generate. 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 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"`
	// 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) 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_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 *protos.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"`
	// The StorePath of the .drv file producing this output.
	// The .drv suffix is omitted in its `name` field.
	Deriver *StorePath `protobuf:"bytes,4,opt,name=deriver,proto3" json:"deriver,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) GetDeriver

func (x *PathInfo) GetDeriver() *StorePath

func (*PathInfo) GetNarinfo

func (x *PathInfo) GetNarinfo() *NARInfo

func (*PathInfo) GetNode

func (x *PathInfo) GetNode() *protos.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 *protos.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, *protos.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