@@ -746,3 +746,111 @@ func ExampleGlideClusterClient_FunctionKillWithRoute() {
746746 // Output:
747747 // Expected error: An error was signalled by the server: - NotBusy: No scripts in execution right now.
748748}
749+
750+ func ExampleGlideClient_FunctionList () {
751+ client := getExampleGlideClient ()
752+
753+ // Load a function first
754+ _ , err := client .FunctionLoad (libraryCode , true )
755+ if err != nil {
756+ fmt .Println ("Glide example failed with an error: " , err )
757+ return
758+ }
759+
760+ query := FunctionListQuery {
761+ LibraryName : "mylib" ,
762+ WithCode : true ,
763+ }
764+
765+ libs , err := client .FunctionList (query )
766+ if err != nil {
767+ fmt .Println ("Glide example failed with an error: " , err )
768+ }
769+
770+ fmt .Printf ("There are %d libraries loaded.\n " , len (libs ))
771+ for i , lib := range libs {
772+ fmt .Printf ("%d) Library name '%s', on engine %s, with %d functions\n " , i + 1 , lib .Name , lib .Engine , len (lib .Functions ))
773+ for j , fn := range lib .Functions {
774+ fmt .Printf (" %d) function '%s'\n " , j + 1 , fn .Name )
775+ }
776+ }
777+ // Output:
778+ // There are 1 libraries loaded.
779+ // 1) Library name 'mylib', on engine LUA, with 1 functions
780+ // 1) function 'myfunc'
781+ }
782+
783+ func ExampleGlideClusterClient_FunctionList () {
784+ client := getExampleGlideClusterClient ()
785+
786+ // Load a function first
787+ _ , err := client .FunctionLoad (libraryCode , true )
788+ if err != nil {
789+ fmt .Println ("Glide example failed with an error: " , err )
790+ return
791+ }
792+
793+ query := FunctionListQuery {
794+ LibraryName : "mylib" ,
795+ WithCode : true ,
796+ }
797+
798+ libs , err := client .FunctionList (query )
799+ if err != nil {
800+ fmt .Println ("Glide example failed with an error: " , err )
801+ }
802+
803+ fmt .Printf ("There are %d libraries loaded.\n " , len (libs ))
804+ for i , lib := range libs {
805+ fmt .Printf ("%d) Library name '%s', on engine %s, with %d functions\n " , i + 1 , lib .Name , lib .Engine , len (lib .Functions ))
806+ for j , fn := range lib .Functions {
807+ fmt .Printf (" %d) function '%s'\n " , j + 1 , fn .Name )
808+ }
809+ }
810+ // Output:
811+ // There are 1 libraries loaded.
812+ // 1) Library name 'mylib', on engine LUA, with 1 functions
813+ // 1) function 'myfunc'
814+ }
815+
816+ func ExampleGlideClusterClient_FunctionListWithRoute () {
817+ client := getExampleGlideClusterClient ()
818+
819+ // Load a function first
820+ route := config .Route (config .AllPrimaries )
821+ opts := options.RouteOption {
822+ Route : route ,
823+ }
824+ _ , err := client .FunctionLoadWithRoute (libraryCode , true , opts )
825+ if err != nil {
826+ fmt .Println ("Glide example failed with an error: " , err )
827+ return
828+ }
829+
830+ // List functions with route
831+ query := FunctionListQuery {
832+ WithCode : true ,
833+ }
834+ result , err := client .FunctionListWithRoute (query , opts )
835+ if err != nil {
836+ fmt .Println ("Glide example failed with an error: " , err )
837+ return
838+ }
839+
840+ // Print results for each node
841+ for _ , libs := range result .MultiValue () {
842+ fmt .Println ("Example Node:" )
843+ for _ , lib := range libs {
844+ fmt .Printf (" Library: %s\n " , lib .Name )
845+ fmt .Printf (" Engine: %s\n " , lib .Engine )
846+ fmt .Printf (" Functions: %d\n " , len (lib .Functions ))
847+ }
848+ break
849+ }
850+
851+ // Output:
852+ // Example Node:
853+ // Library: mylib
854+ // Engine: LUA
855+ // Functions: 1
856+ }
0 commit comments