diff --git a/README.md b/README.md index a568844..6b1c318 100644 --- a/README.md +++ b/README.md @@ -274,6 +274,21 @@ taxonomyTx, err := composedActions.InsertTaxonomy(ctx, types.Taxonomy{ }, }, }) + +// Get taxonomy information for a composed stream +taxonomyParams := types.DescribeTaxonomiesParams{ + Stream: tnClient.OwnStreamLocator(composedStreamId), + LatestVersion: true, +} +taxonomyItems, err := composedActions.DescribeTaxonomies(ctx, taxonomyParams) +if err != nil { + log.Printf("Failed to describe taxonomies: %v", err) +} else { + for _, item := range taxonomyItems { + fmt.Printf("Child stream: %s, Weight: %.2f\n", + item.ChildStream.StreamId.String(), item.Weight) + } +} ``` ### Complex Stream Creation Example @@ -468,9 +483,31 @@ func main() { By following these guidelines, you can effectively manage stream resources in the TRUF.NETWORK ecosystem. +## Quick Reference + +### Common Operations + +| Operation | Method | +|-----------|--------| +| Deploy primitive stream | `tnClient.DeployStream(ctx, streamId, types.StreamTypePrimitive)` | +| Deploy composed stream | `tnClient.DeployStream(ctx, streamId, types.StreamTypeComposed)` | +| Insert records | `primitiveActions.InsertRecords(ctx, records)` | +| Get stream data | `composedActions.GetRecord(ctx, input)` | +| Set stream taxonomy | `composedActions.InsertTaxonomy(ctx, taxonomy)` | +| Get stream taxonomy | `composedActions.DescribeTaxonomies(ctx, params)` | +| Destroy stream | `tnClient.DestroyStream(ctx, streamId)` | + +### Key Types + +- `types.StreamTypePrimitive` - Raw data streams +- `types.StreamTypeComposed` - Aggregated streams with taxonomy +- `types.DescribeTaxonomiesParams` - Parameters for querying taxonomies +- `types.TaxonomyItem` - Individual child stream with weight + ## Further Reading - [TN-SDK Documentation](./docs/readme.md) +- [API Reference](./docs/api-reference.md) - Complete method documentation including taxonomy operations - [Truflation Whitepaper](https://whitepaper.truflation.com/) For additional support or questions, please [open an issue](https://github.com/trufnetwork/sdk-go/issues) or contact our support team. diff --git a/docs/api-reference.md b/docs/api-reference.md index 4eaad6d..df8bb1f 100644 --- a/docs/api-reference.md +++ b/docs/api-reference.md @@ -19,7 +19,7 @@ The SDK is structured around several key interfaces: - [Client](#client-interface): Primary entry point for network interactions - [Stream](#stream-interface): Core stream operations and access control - [Primitive Stream](#primitive-stream-interface): Raw data stream management -- [Composed Stream](#composed-stream-interface): Aggregated data stream handling +- [Composed Stream](#composed-stream-interface): Aggregated data stream handling and taxonomy management ## Core Concepts @@ -885,26 +885,48 @@ taxonomy := types.Taxonomy{ ### Methods -#### `DescribeTaxonomies` +#### `DescribeTaxonomies` 🔍 ```go DescribeTaxonomies(ctx context.Context, params types.DescribeTaxonomiesParams) ([]types.TaxonomyItem, error) ``` -Retrieves the current taxonomy configuration for a composed stream. +Retrieves the current taxonomy configuration for a composed stream. This is the key method for discovering how composed streams aggregate their child streams. **Parameters:** - `ctx`: Operation context - `params`: Taxonomy description parameters - - `Stream`: Stream locator - - `LatestVersion`: Flag to return only the most recent taxonomy + - `Stream`: Stream locator (identifies the composed stream) + - `LatestVersion`: Flag to return only the most recent taxonomy version **Returns:** -- List of taxonomy items +- List of `TaxonomyItem` objects containing: + - `ChildStream`: Locator of each child stream + - `Weight`: Weight/contribution of each child stream (0.0 to 1.0) - Error if retrieval fails +**Example Usage:** +```go +// Get the latest taxonomy for a composed stream +params := types.DescribeTaxonomiesParams{ + Stream: tnClient.OwnStreamLocator(composedStreamId), + LatestVersion: true, +} +taxonomyItems, err := composedActions.DescribeTaxonomies(ctx, params) +if err != nil { + log.Printf("Failed to describe taxonomies: %v", err) + return +} + +fmt.Printf("Taxonomy for stream %s:\n", composedStreamId.String()) +for _, item := range taxonomyItems { + fmt.Printf(" Child: %s (Weight: %.2f)\n", + item.ChildStream.StreamId.String(), item.Weight) +} +``` + #### `SetTaxonomy` ```go