Exemple de code SDK
src/main.go
Ce fichier contient du code d'exemple pour illustrer comment utiliser le SDK pour catégoriser des URL.
Vous pouvez lancer directement le binaire via docker en utilisant ./scripts/client.sh ou manuellement en utilisant la chaine d'outils de go.
Paramètres requis
Si vous utilisez directement le binaire, au moins deux arguments sont requis :
le DSN Redis avec
-rdb -dsn,au moins un domaine à classer.
Ce code importe le paquet gitlab.olfeo.tech/data-tools/nexus/sdk/redis en tant que rdb du SDK. Il crée ensuite la structure redisDatabase, qui implémente l'interface Database. Cette interface est passées à la fonction categorize.NewCategorizer qui catégorise les domaines.
Elle retourne deux informations :
la catégorie du domaine en appelant
Categorizer.GetDomainCategoryetDatabase.GetCategoryInfol'application associée (si elle existe) et sa catégorie en appelant
Categorizer.GetDomainApplications,Database.GetApplicationInfoetDatabase.GetApplicationCategoryInfo
sdk-sample$ cd src src$ go run main.go -rdb-dsn redis://localhost:6379 dropbox.com Using rdb categorizer from redis://localhost:6379: dropbox.com: (15181) Online Data Storage dropbox.com: application (27) Dropbox application category: (10005) Online Software providing cloud back-ups and data storage infrastructure