Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cbindings/collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func parseCollectionOptionsToGetCollectionsOptions(
func getCollection(
store client.Store,
ctx context.Context,
builder options.Lister[options.GetCollectionsOptions],
builder options.Enumerable[options.GetCollectionsOptions],
) (client.Collection, error) {
cols, err := store.GetCollections(ctx, builder)
if err != nil {
Expand Down
72 changes: 37 additions & 35 deletions cbindings/wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ func NewCWrapper(node *node.Node) (*CWrapper, error) {
}, nil
}

func (w *CWrapper) PeerInfo(ctx context.Context, opts ...options.Lister[options.PeerInfoOptions]) ([]string, error) {
func (w *CWrapper) PeerInfo(
ctx context.Context, opts ...options.Enumerable[options.PeerInfoOptions],
) ([]string, error) {
cIdentity := optionToUintptr(utils.NewOptions(opts...).GetIdentity())
defer C.IdentityFree(cIdentity)

Expand All @@ -131,7 +133,7 @@ func (w *CWrapper) PeerInfo(ctx context.Context, opts ...options.Lister[options.

func (w *CWrapper) ActivePeers(
ctx context.Context,
opts ...options.Lister[options.ActivePeersOptions],
opts ...options.Enumerable[options.ActivePeersOptions],
) ([]string, error) {
opt := utils.NewOptions(opts...)
cIdentity := optionToUintptr(opt.GetIdentity())
Expand All @@ -153,7 +155,7 @@ func (w *CWrapper) ActivePeers(
func (w *CWrapper) CreateReplicator(
ctx context.Context,
addresses []string,
opts ...options.Lister[options.CreateReplicatorOptions],
opts ...options.Enumerable[options.CreateReplicatorOptions],
) error {
opt := utils.NewOptions(opts...)
addrStr := C.CString(strings.Join(addresses, ","))
Expand All @@ -174,7 +176,7 @@ func (w *CWrapper) CreateReplicator(
func (w *CWrapper) DeleteReplicator(
ctx context.Context,
id string,
opts ...options.Lister[options.DeleteReplicatorOptions],
opts ...options.Enumerable[options.DeleteReplicatorOptions],
) error {
opt := utils.NewOptions(opts...)
peerID := C.CString(id)
Expand All @@ -194,7 +196,7 @@ func (w *CWrapper) DeleteReplicator(

func (w *CWrapper) ListReplicators(
ctx context.Context,
opts ...options.Lister[options.ListReplicatorsOptions],
opts ...options.Enumerable[options.ListReplicatorsOptions],
) ([]client.Replicator, error) {
cIdentity := optionToUintptr(utils.NewOptions(opts...).GetIdentity())
defer C.IdentityFree(cIdentity)
Expand All @@ -214,7 +216,7 @@ func (w *CWrapper) ListReplicators(
func (w *CWrapper) CreateP2PCollections(
ctx context.Context,
collectionIDs []string,
opts ...options.Lister[options.CreateP2PCollectionsOptions],
opts ...options.Enumerable[options.CreateP2PCollectionsOptions],
) error {
cIdentity := optionToUintptr(utils.NewOptions(opts...).GetIdentity())
colStr := C.CString(strings.Join(collectionIDs, ","))
Expand All @@ -231,7 +233,7 @@ func (w *CWrapper) CreateP2PCollections(
func (w *CWrapper) DeleteP2PCollections(
ctx context.Context,
collectionIDs []string,
opts ...options.Lister[options.DeleteP2PCollectionsOptions],
opts ...options.Enumerable[options.DeleteP2PCollectionsOptions],
) error {
colStr := C.CString(strings.Join(collectionIDs, ","))
cIdentity := optionToUintptr(utils.NewOptions(opts...).GetIdentity())
Expand All @@ -248,7 +250,7 @@ func (w *CWrapper) DeleteP2PCollections(

func (w *CWrapper) ListP2PCollections(
ctx context.Context,
opts ...options.Lister[options.ListP2PCollectionsOptions],
opts ...options.Enumerable[options.ListP2PCollectionsOptions],
) ([]string, error) {
cIdentity := optionToUintptr(utils.NewOptions(opts...).GetIdentity())
defer C.IdentityFree(cIdentity)
Expand All @@ -268,7 +270,7 @@ func (w *CWrapper) ListP2PCollections(
func (w *CWrapper) CreateP2PDocuments(
ctx context.Context,
docIDs []string,
opts ...options.Lister[options.CreateP2PDocumentsOptions],
opts ...options.Enumerable[options.CreateP2PDocumentsOptions],
) error {
docStr := C.CString(strings.Join(docIDs, ","))
cIdentity := optionToUintptr(utils.NewOptions(opts...).GetIdentity())
Expand All @@ -286,7 +288,7 @@ func (w *CWrapper) CreateP2PDocuments(
func (w *CWrapper) DeleteP2PDocuments(
ctx context.Context,
docIDs []string,
opts ...options.Lister[options.DeleteP2PDocumentsOptions],
opts ...options.Enumerable[options.DeleteP2PDocumentsOptions],
) error {
docStr := C.CString(strings.Join(docIDs, ","))
cIdentity := optionToUintptr(utils.NewOptions(opts...).GetIdentity())
Expand All @@ -303,7 +305,7 @@ func (w *CWrapper) DeleteP2PDocuments(

func (w *CWrapper) ListP2PDocuments(
ctx context.Context,
opts ...options.Lister[options.ListP2PDocumentsOptions],
opts ...options.Enumerable[options.ListP2PDocumentsOptions],
) ([]string, error) {
cIdentity := optionToUintptr(utils.NewOptions(opts...).GetIdentity())
defer C.IdentityFree(cIdentity)
Expand Down Expand Up @@ -350,7 +352,7 @@ func (w *CWrapper) SyncDocuments(
func (w *CWrapper) SyncCollectionVersions(
ctx context.Context,
versionIDs []string,
opts ...options.Lister[options.SyncCollectionVersionsOptions],
opts ...options.Enumerable[options.SyncCollectionVersionsOptions],
) error {
opt := utils.NewOptions(opts...)
versions := C.CString(strings.Join(versionIDs, ","))
Expand Down Expand Up @@ -379,7 +381,7 @@ func (w *CWrapper) SyncCollectionVersions(
func (w *CWrapper) SyncBranchableCollection(
ctx context.Context,
collectionID string,
opts ...options.Lister[options.SyncBranchableCollectionOptions],
opts ...options.Enumerable[options.SyncBranchableCollectionOptions],
) error {
opt := utils.NewOptions(opts...)
cCollectionID := C.CString(collectionID)
Expand Down Expand Up @@ -412,15 +414,15 @@ func (w *CWrapper) BasicImport(ctx context.Context, filepath string) error {
func (w *CWrapper) BasicExport(
ctx context.Context,
filepath string,
opts ...options.Lister[options.BasicExportOptions],
opts ...options.Enumerable[options.BasicExportOptions],
) error {
panic("not implemented")
}

func (w *CWrapper) AddSchema(
ctx context.Context,
schema string,
opts ...options.Lister[options.AddSchemaOptions],
opts ...options.Enumerable[options.AddSchemaOptions],
) ([]client.CollectionVersion, error) {
cIdentity := optionToUintptr(utils.NewOptions(opts...).GetIdentity())
defer C.IdentityFree(cIdentity)
Expand All @@ -444,7 +446,7 @@ func (w *CWrapper) AddSchema(
func (w *CWrapper) AddDACPolicy(
ctx context.Context,
policy string,
opts ...options.Lister[options.AddDACPolicyOptions],
opts ...options.Enumerable[options.AddDACPolicyOptions],
) (client.AddPolicyResult, error) {
cIdentity := optionToUintptr(utils.NewOptions(opts...).GetIdentity())
defer C.IdentityFree(cIdentity)
Expand All @@ -471,7 +473,7 @@ func (w *CWrapper) AddDACActorRelationship(
docID string,
relation string,
targetActor string,
opts ...options.Lister[options.AddDACActorRelationshipOptions],
opts ...options.Enumerable[options.AddDACActorRelationshipOptions],
) (client.AddActorRelationshipResult, error) {
cIdentity := optionToUintptr(utils.NewOptions(opts...).GetIdentity())
cCollectionName := C.CString(collectionName)
Expand Down Expand Up @@ -512,7 +514,7 @@ func (w *CWrapper) DeleteDACActorRelationship(
docID string,
relation string,
targetActor string,
opts ...options.Lister[options.DeleteDACActorRelationshipOptions],
opts ...options.Enumerable[options.DeleteDACActorRelationshipOptions],
) (client.DeleteActorRelationshipResult, error) {
cIdentity := optionToUintptr(utils.NewOptions(opts...).GetIdentity())
cCollectionName := C.CString(collectionName)
Expand Down Expand Up @@ -548,7 +550,7 @@ func (w *CWrapper) DeleteDACActorRelationship(

func (w *CWrapper) GetNACStatus(
ctx context.Context,
opts ...options.Lister[options.GetNACStatusOptions],
opts ...options.Enumerable[options.GetNACStatusOptions],
) (client.NACStatusResult, error) {
cIdentity := optionToUintptr(utils.NewOptions(opts...).GetIdentity())
defer C.IdentityFree(cIdentity)
Expand All @@ -562,7 +564,7 @@ func (w *CWrapper) GetNACStatus(
return unmarshalResult[client.NACStatusResult](res.Value)
}

func (w *CWrapper) ReEnableNAC(ctx context.Context, opts ...options.Lister[options.ReEnableNACOptions]) error {
func (w *CWrapper) ReEnableNAC(ctx context.Context, opts ...options.Enumerable[options.ReEnableNACOptions]) error {
cIdentity := optionToUintptr(utils.NewOptions(opts...).GetIdentity())
defer C.IdentityFree(cIdentity)

Expand All @@ -575,7 +577,7 @@ func (w *CWrapper) ReEnableNAC(ctx context.Context, opts ...options.Lister[optio
return nil
}

func (w *CWrapper) DisableNAC(ctx context.Context, opts ...options.Lister[options.DisableNACOptions]) error {
func (w *CWrapper) DisableNAC(ctx context.Context, opts ...options.Enumerable[options.DisableNACOptions]) error {
cIdentity := optionToUintptr(utils.NewOptions(opts...).GetIdentity())
defer C.IdentityFree(cIdentity)

Expand All @@ -592,7 +594,7 @@ func (w *CWrapper) AddNACActorRelationship(
ctx context.Context,
relation string,
targetActor string,
opts ...options.Lister[options.AddNACActorRelationshipOptions],
opts ...options.Enumerable[options.AddNACActorRelationshipOptions],
) (client.AddActorRelationshipResult, error) {
cIdentity := optionToUintptr(utils.NewOptions(opts...).GetIdentity())
cRelation := C.CString(relation)
Expand All @@ -615,7 +617,7 @@ func (w *CWrapper) DeleteNACActorRelationship(
ctx context.Context,
relation string,
targetActor string,
opts ...options.Lister[options.DeleteNACActorRelationshipOptions],
opts ...options.Enumerable[options.DeleteNACActorRelationshipOptions],
) (client.DeleteActorRelationshipResult, error) {
cIdentity := optionToUintptr(utils.NewOptions(opts...).GetIdentity())
cRelation := C.CString(relation)
Expand All @@ -636,7 +638,7 @@ func (w *CWrapper) PatchCollection(
ctx context.Context,
patch string,
migration immutable.Option[model.Lens],
opts ...options.Lister[options.PatchCollectionOptions],
opts ...options.Enumerable[options.PatchCollectionOptions],
) error {
cPatch := C.CString(patch)
cIdentity := optionToUintptr(utils.NewOptions(opts...).GetIdentity())
Expand Down Expand Up @@ -668,7 +670,7 @@ func (w *CWrapper) PatchCollection(
func (w *CWrapper) SetActiveCollectionVersion(
ctx context.Context,
collectionVersionID string,
opts ...options.Lister[options.SetActiveCollectionVersionOptions],
opts ...options.Enumerable[options.SetActiveCollectionVersionOptions],
) error {
cIdentity := optionToUintptr(utils.NewOptions(opts...).GetIdentity())
cVersion := C.CString(collectionVersionID)
Expand Down Expand Up @@ -699,7 +701,7 @@ func (w *CWrapper) AddView(
ctx context.Context,
query string,
sdl string,
opts ...options.Lister[options.AddViewOptions],
opts ...options.Enumerable[options.AddViewOptions],
) ([]client.CollectionVersion, error) {
opt := utils.NewOptions(opts...)

Expand Down Expand Up @@ -727,7 +729,7 @@ func (w *CWrapper) AddView(
return colDefRes, nil
}

func (w *CWrapper) RefreshViews(ctx context.Context, opts ...options.Lister[options.RefreshViewsOptions]) error {
func (w *CWrapper) RefreshViews(ctx context.Context, opts ...options.Enumerable[options.RefreshViewsOptions]) error {
opt := utils.NewOptions(opts...)
copts := getCollectionsOptionsToCOptions(opt)
defer C.free(unsafe.Pointer(copts.version))
Expand Down Expand Up @@ -770,7 +772,7 @@ func (w *CWrapper) SetMigration(ctx context.Context, config client.LensConfig) (
func (w *CWrapper) AddLens(
ctx context.Context,
lens model.Lens,
opts ...options.Lister[options.AddLensOptions],
opts ...options.Enumerable[options.AddLensOptions],
) (string, error) {
lensConfig, err := json.Marshal(lens)
if err != nil {
Expand All @@ -793,7 +795,7 @@ func (w *CWrapper) AddLens(

func (w *CWrapper) ListLenses(
ctx context.Context,
opts ...options.Lister[options.ListLensesOptions],
opts ...options.Enumerable[options.ListLensesOptions],
) (map[string]model.Lens, error) {
cIdentity := optionToUintptr(utils.NewOptions(opts...).GetIdentity())
defer C.IdentityFree(cIdentity)
Expand All @@ -815,7 +817,7 @@ func (w *CWrapper) ListLenses(
func (w *CWrapper) GetCollectionByName(
ctx context.Context,
name client.CollectionName,
opts ...options.Lister[options.GetCollectionByNameOptions],
opts ...options.Enumerable[options.GetCollectionByNameOptions],
) (client.Collection, error) {
cols, err := w.GetCollections(ctx, options.GetCollections().SetCollectionName(name))
if err != nil {
Expand Down Expand Up @@ -861,7 +863,7 @@ func getCollectionsOptionsToCOptions(opts *options.GetCollectionsOptions) C.Coll

func (w *CWrapper) GetCollections(
ctx context.Context,
opts ...options.Lister[options.GetCollectionsOptions],
opts ...options.Enumerable[options.GetCollectionsOptions],
) ([]client.Collection, error) {
copts := getCollectionsOptionsToCOptions(utils.NewOptions(opts...))
defer C.free(unsafe.Pointer(copts.version))
Expand Down Expand Up @@ -892,7 +894,7 @@ func (w *CWrapper) GetCollections(

func (w *CWrapper) GetAllIndexes(
ctx context.Context,
opts ...options.Lister[options.GetAllIndexesOptions],
opts ...options.Enumerable[options.GetAllIndexesOptions],
) (map[client.CollectionName][]client.IndexDescription, error) {
cVersion := C.CString("")
cCollectionID := C.CString("")
Expand Down Expand Up @@ -948,7 +950,7 @@ func (w *CWrapper) ListAllEncryptedIndexes(
func (w *CWrapper) ExecRequest(
ctx context.Context,
query string,
opts ...options.Lister[options.ExecRequestOptions],
opts ...options.Enumerable[options.ExecRequestOptions],
) *client.RequestResult {
execRequestOpts := utils.NewOptions(opts...)
operation, variables, err := extractStringsFromRequestOptions(execRequestOpts)
Expand Down Expand Up @@ -1057,7 +1059,7 @@ func (w *CWrapper) PrintDump(ctx context.Context) error {
func (w *CWrapper) Connect(
ctx context.Context,
addresses []string,
opts ...options.Lister[options.ConnectOptions],
opts ...options.Enumerable[options.ConnectOptions],
) error {
cIdentity := optionToUintptr(utils.NewOptions(opts...).GetIdentity())
cPeerAddresses := C.CString(strings.Join(addresses, ","))
Expand Down Expand Up @@ -1095,7 +1097,7 @@ func (w *CWrapper) VerifySignature(
ctx context.Context,
blockCid string,
pubKey crypto.PublicKey,
opts ...options.Lister[options.VerifySignatureOptions],
opts ...options.Enumerable[options.VerifySignatureOptions],
) error {
cPubKey := C.CString(pubKey.String())
cKeyType := C.CString(string(pubKey.Type()))
Expand Down
Loading
Loading