You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/docs/core/flow_def.mdx
+39-8Lines changed: 39 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -416,22 +416,28 @@ flow_builder.declare(
416
416
### Auth Registry
417
417
418
418
CocoIndex manages an auth registry. It's an in-memory key-value store, mainly to store authentication information for a backend.
419
+
It's usually used for targets, where key stability is important for backend cleanup.
419
420
420
-
Operation spec is the default way to configure a persistent backend. But it has the following limitations:
421
+
Operation spec is the default way to configure sources, functions and targets. But it has the following limitations:
421
422
422
423
* The spec isn't supposed to contain secret information, and it's frequently shown in various places, e.g. `cocoindex show`.
423
-
*Once an operation is removed after flow definition code change, the spec is also gone.
424
-
But we still need to be able to drop the backend (e.g. a table) when [setup / drop flow](/docs/core/flow_methods#setup--drop-flow).
424
+
*For targets, once an operation is removed after flow definition code change, the spec is also gone.
425
+
But we still need to be able to drop the persistent backend (e.g. a table) when [setup / drop flow](/docs/core/flow_methods#setup--drop-flow).
425
426
426
-
Auth registry is introduced to solve the problems above. It works as follows:
427
+
Auth registry is introduced to solve the problems above.
427
428
428
-
* You can create new **auth entry** by a key and a value.
429
-
* You can references the entry by the key, and pass it as part of spec for certain operations. e.g. `Neo4j` takes `connection` field in the form of auth entry reference.
429
+
430
+
#### Auth Entry
431
+
432
+
An auth entry is an entry in the auth registry with an explicit key.
433
+
434
+
* You can create new *auth entry* by a key and a value.
435
+
* You can reference the entry by the key, and pass it as part of spec for certain operations. e.g. `Neo4j` takes `connection` field in the form of auth entry reference.
430
436
431
437
<Tabs>
432
438
<TabItemvalue="python"label="Python"default>
433
439
434
-
You can add an auth entry by `cocoindex.add_auth_entry()` function, which returns a `cocoindex.AuthEntryReference`:
440
+
You can add an auth entry by `cocoindex.add_auth_entry()` function, which returns a `cocoindex.AuthEntryReference[T]`:
Then reference it when building a spec that takes an auth entry:
447
453
448
-
* You can either reference by the `AuthEntryReference` object directly:
454
+
* You can either reference by the `AuthEntryReference[T]` object directly:
449
455
450
456
```python
451
457
demo_collector.export(
@@ -472,3 +478,28 @@ Note that CocoIndex backends use the key of an auth entry to identify the backen
472
478
473
479
* If a key is no longer referenced in any operation spec, keep it until the next flow setup / drop action,
474
480
so that CocoIndex will be able to clean up the backends.
481
+
482
+
#### Transient Auth Entry
483
+
484
+
A transient auth entry is an entry in the auth registry with an automatically generated key.
485
+
It's usually used for sources and functions, where key stability is not important.
486
+
487
+
<Tabs>
488
+
<TabItemvalue="python"label="Python"default>
489
+
490
+
You can create a new *transient auth entry* by `cocoindex.add_transient_auth_entry()` function, which returns a `cocoindex.TransientAuthEntryReference[T]`, and pass it to a source or function spec that takes it, e.g.
Whenever a `TransientAuthEntryReference[T]` is expected, you can also pass a `AuthEntryReference[T]` instead, as `AuthEntryReference[T]` is a subtype of `TransientAuthEntryReference[T]`.
0 commit comments