@ -7,12 +7,12 @@ import (
)
)
var gql_interface_graph_node * graphql . Interface = nil
var gql_interface_graph_node * graphql . Interface = nil
func GQLInterface Graph Node( ) * graphql . Interface {
func GQLInterface Node( ) * graphql . Interface {
if gql_interface_graph_node == nil {
if gql_interface_graph_node == nil {
gql_interface_graph_node = graphql . NewInterface ( graphql . InterfaceConfig {
gql_interface_graph_node = graphql . NewInterface ( graphql . InterfaceConfig {
Name : " Graph Node",
Name : " Node",
ResolveType : func ( p graphql . ResolveTypeParams ) * graphql . Object {
ResolveType : func ( p graphql . ResolveTypeParams ) * graphql . Object {
ctx , ok := p . Context . Value ( "graph_context" ) . ( * Graph Context)
ctx , ok := p . Context . Value ( "graph_context" ) . ( * Context)
if ok == false {
if ok == false {
return nil
return nil
}
}
@ -39,10 +39,6 @@ func GQLInterfaceGraphNode() *graphql.Interface {
gql_interface_graph_node . AddFieldConfig ( "ID" , & graphql . Field {
gql_interface_graph_node . AddFieldConfig ( "ID" , & graphql . Field {
Type : graphql . String ,
Type : graphql . String ,
} )
} )
gql_interface_graph_node . AddFieldConfig ( "Name" , & graphql . Field {
Type : graphql . String ,
} )
}
}
return gql_interface_graph_node
return gql_interface_graph_node
@ -62,7 +58,7 @@ func GQLInterfaceThread() *graphql.Interface {
gql_interface_thread = graphql . NewInterface ( graphql . InterfaceConfig {
gql_interface_thread = graphql . NewInterface ( graphql . InterfaceConfig {
Name : "Thread" ,
Name : "Thread" ,
ResolveType : func ( p graphql . ResolveTypeParams ) * graphql . Object {
ResolveType : func ( p graphql . ResolveTypeParams ) * graphql . Object {
ctx , ok := p . Context . Value ( "graph_context" ) . ( * Graph Context)
ctx , ok := p . Context . Value ( "graph_context" ) . ( * Context)
if ok == false {
if ok == false {
return nil
return nil
}
}
@ -133,7 +129,7 @@ func GQLInterfaceLockable() *graphql.Interface {
gql_interface_lockable = graphql . NewInterface ( graphql . InterfaceConfig {
gql_interface_lockable = graphql . NewInterface ( graphql . InterfaceConfig {
Name : "Lockable" ,
Name : "Lockable" ,
ResolveType : func ( p graphql . ResolveTypeParams ) * graphql . Object {
ResolveType : func ( p graphql . ResolveTypeParams ) * graphql . Object {
ctx , ok := p . Context . Value ( "graph_context" ) . ( * Graph Context)
ctx , ok := p . Context . Value ( "graph_context" ) . ( * Context)
if ok == false {
if ok == false {
return nil
return nil
}
}
@ -186,27 +182,27 @@ func GQLInterfaceLockable() *graphql.Interface {
}
}
func GQLNodeID ( p graphql . ResolveParams ) ( interface { } , error ) {
func GQLNodeID ( p graphql . ResolveParams ) ( interface { } , error ) {
node , ok := p . Source . ( Graph Node)
node , ok := p . Source . ( Node)
if ok == false || node == nil {
if ok == false || node == nil {
return nil , fmt . Errorf ( "Failed to cast source to Graph Node")
return nil , fmt . Errorf ( "Failed to cast source to Node")
}
}
return node . ID ( ) , nil
return node . ID ( ) , nil
}
}
func GQL NodeName ( p graphql . ResolveParams ) ( interface { } , error ) {
func GQL ThreadListen ( p graphql . ResolveParams ) ( interface { } , error ) {
node , ok := p . Source . ( G raphNo de )
node , ok := p . Source . ( * G QLTh re ad)
if ok == false || node == nil {
if ok == false || node == nil {
return nil , fmt . Errorf ( "Failed to cast source to G raphNo de ")
return nil , fmt . Errorf ( "Failed to cast source to G QLTh re ad")
}
}
ctx , ok := p . Context . Value ( "graph_context" ) . ( * Graph Context)
ctx , ok := p . Context . Value ( "graph_context" ) . ( * Context)
if ok == false {
if ok == false {
return nil , fmt . Errorf ( "Failed to cast context graph_context to Graph Context")
return nil , fmt . Errorf ( "Failed to cast context graph_context to Context")
}
}
name := ""
listen := ""
err := UseStates ( ctx , [ ] Graph Node{ node } , func ( states NodeStat eMap) ( error ) {
err := UseStates ( ctx , [ ] Node{ node } , func ( nodes Nod eMap) ( error ) {
name = states [ node . ID ( ) ] . Name ( )
listen = node . Listen
return nil
return nil
} )
} )
@ -214,27 +210,23 @@ func GQLNodeName(p graphql.ResolveParams) (interface{}, error) {
return nil , err
return nil , err
}
}
return name , nil
return listen , nil
}
}
func GQLThread Listen ( p graphql . ResolveParams ) ( interface { } , error ) {
func GQLThread Parent ( p graphql . ResolveParams ) ( interface { } , error ) {
node , ok := p . Source . ( * GQL Thread)
node , ok := p . Source . ( Thread)
if ok == false || node == nil {
if ok == false || node == nil {
return nil , fmt . Errorf ( "Failed to cast source to GQL Thread")
return nil , fmt . Errorf ( "Failed to cast source to Thread")
}
}
ctx , ok := p . Context . Value ( "graph_context" ) . ( * Graph Context)
ctx , ok := p . Context . Value ( "graph_context" ) . ( * Context)
if ok == false {
if ok == false {
return nil , fmt . Errorf ( "Failed to cast context graph_context to Graph Context")
return nil , fmt . Errorf ( "Failed to cast context graph_context to Context")
}
}
listen := ""
var parent Thread = nil
err := UseStates ( ctx , [ ] GraphNode { node } , func ( states NodeStateMap ) ( error ) {
err := UseStates ( ctx , [ ] Node { node } , func ( nodes NodeMap ) ( error ) {
gql_thread , ok := states [ node . ID ( ) ] . ( * GQLThreadState )
parent = node . Parent ( )
if ok == false {
return fmt . Errorf ( "Failed to cast state to GQLThreadState" )
}
listen = gql_thread . Listen
return nil
return nil
} )
} )
@ -242,27 +234,23 @@ func GQLThreadListen(p graphql.ResolveParams) (interface{}, error) {
return nil , err
return nil , err
}
}
return listen , nil
return parent , nil
}
}
func GQLThread Parent ( p graphql . ResolveParams ) ( interface { } , error ) {
func GQLThread Children ( p graphql . ResolveParams ) ( interface { } , error ) {
node , ok := p . Source . ( Thread )
node , ok := p . Source . ( Thread )
if ok == false || node == nil {
if ok == false || node == nil {
return nil , fmt . Errorf ( "Failed to cast source to Thread" )
return nil , fmt . Errorf ( "Failed to cast source to Thread" )
}
}
ctx , ok := p . Context . Value ( "graph_context" ) . ( * Graph Context)
ctx , ok := p . Context . Value ( "graph_context" ) . ( * Context)
if ok == false {
if ok == false {
return nil , fmt . Errorf ( "Failed to cast context graph_context to Graph Context")
return nil , fmt . Errorf ( "Failed to cast context graph_context to Context")
}
}
var parent Thread = nil
var children [ ] Thread = nil
err := UseStates ( ctx , [ ] GraphNode { node } , func ( states NodeStateMap ) ( error ) {
err := UseStates ( ctx , [ ] Node { node } , func ( nodes NodeMap ) ( error ) {
gql_thread , ok := states [ node . ID ( ) ] . ( ThreadState )
children = node . Children ( )
if ok == false {
return fmt . Errorf ( "Failed to cast state to ThreadState" )
}
parent = gql_thread . Parent ( )
return nil
return nil
} )
} )
@ -270,27 +258,23 @@ func GQLThreadParent(p graphql.ResolveParams) (interface{}, error) {
return nil , err
return nil , err
}
}
return parent , nil
return children , nil
}
}
func GQL ThreadChildren ( p graphql . ResolveParams ) ( interface { } , error ) {
func GQL LockableName ( p graphql . ResolveParams ) ( interface { } , error ) {
node , ok := p . Source . ( Thread )
node , ok := p . Source . ( Lockable )
if ok == false || node == nil {
if ok == false || node == nil {
return nil , fmt . Errorf ( "Failed to cast source to Thread ")
return nil , fmt . Errorf ( "Failed to cast source to Lockable ")
}
}
ctx , ok := p . Context . Value ( "graph_context" ) . ( * Graph Context)
ctx , ok := p . Context . Value ( "graph_context" ) . ( * Context)
if ok == false {
if ok == false || node == nil {
return nil , fmt . Errorf ( "Failed to cast context graph_context to Graph Context")
return nil , fmt . Errorf ( "Failed to cast context graph_context to Context")
}
}
var children [ ] Thread = nil
name := ""
err := UseStates ( ctx , [ ] GraphNode { node } , func ( states NodeStateMap ) ( error ) {
err := UseStates ( ctx , [ ] Node { node } , func ( nodes NodeMap ) error {
gql_thread , ok := states [ node . ID ( ) ] . ( ThreadState )
name = node . Name ( )
if ok == false {
return fmt . Errorf ( "Failed to cast state to ThreadState" )
}
children = gql_thread . Children ( )
return nil
return nil
} )
} )
@ -298,7 +282,7 @@ func GQLThreadChildren(p graphql.ResolveParams) (interface{}, error) {
return nil , err
return nil , err
}
}
return children , nil
return name , nil
}
}
func GQLLockableRequirements ( p graphql . ResolveParams ) ( interface { } , error ) {
func GQLLockableRequirements ( p graphql . ResolveParams ) ( interface { } , error ) {
@ -307,18 +291,14 @@ func GQLLockableRequirements(p graphql.ResolveParams) (interface{}, error) {
return nil , fmt . Errorf ( "Failed to cast source to Lockable" )
return nil , fmt . Errorf ( "Failed to cast source to Lockable" )
}
}
ctx , ok := p . Context . Value ( "graph_context" ) . ( * Graph Context)
ctx , ok := p . Context . Value ( "graph_context" ) . ( * Context)
if ok == false {
if ok == false {
return nil , fmt . Errorf ( "Failed to cast context graph_context to Graph Context")
return nil , fmt . Errorf ( "Failed to cast context graph_context to Context")
}
}
var requirements [ ] Lockable = nil
var requirements [ ] Lockable = nil
err := UseStates ( ctx , [ ] GraphNode { node } , func ( states NodeStateMap ) ( error ) {
err := UseStates ( ctx , [ ] Node { node } , func ( nodes NodeMap ) ( error ) {
gql_thread , ok := states [ node . ID ( ) ] . ( LockableState )
requirements = node . Requirements ( )
if ok == false {
return fmt . Errorf ( "Failed to cast state to LockableState" )
}
requirements = gql_thread . Requirements ( )
return nil
return nil
} )
} )
@ -335,18 +315,14 @@ func GQLLockableDependencies(p graphql.ResolveParams) (interface{}, error) {
return nil , fmt . Errorf ( "Failed to cast source to Lockable" )
return nil , fmt . Errorf ( "Failed to cast source to Lockable" )
}
}
ctx , ok := p . Context . Value ( "graph_context" ) . ( * Graph Context)
ctx , ok := p . Context . Value ( "graph_context" ) . ( * Context)
if ok == false {
if ok == false {
return nil , fmt . Errorf ( "Failed to cast context graph_context to Graph Context")
return nil , fmt . Errorf ( "Failed to cast context graph_context to Context")
}
}
var dependencies [ ] Lockable = nil
var dependencies [ ] Lockable = nil
err := UseStates ( ctx , [ ] GraphNode { node } , func ( states NodeStateMap ) ( error ) {
err := UseStates ( ctx , [ ] Node { node } , func ( nodes NodeMap ) ( error ) {
gql_thread , ok := states [ node . ID ( ) ] . ( LockableState )
dependencies = node . Dependencies ( )
if ok == false {
return fmt . Errorf ( "Failed to cast state to LockableState" )
}
dependencies = gql_thread . Dependencies ( )
return nil
return nil
} )
} )
@ -363,18 +339,14 @@ func GQLLockableOwner(p graphql.ResolveParams) (interface{}, error) {
return nil , fmt . Errorf ( "Failed to cast source to Lockable" )
return nil , fmt . Errorf ( "Failed to cast source to Lockable" )
}
}
ctx , ok := p . Context . Value ( "graph_context" ) . ( * Graph Context)
ctx , ok := p . Context . Value ( "graph_context" ) . ( * Context)
if ok == false {
if ok == false {
return nil , fmt . Errorf ( "Failed to cast context graph_context to Graph Context")
return nil , fmt . Errorf ( "Failed to cast context graph_context to Context")
}
}
var owner GraphNode = nil
var owner Node = nil
err := UseStates ( ctx , [ ] GraphNode { node } , func ( states NodeStateMap ) ( error ) {
err := UseStates ( ctx , [ ] Node { node } , func ( nodes NodeMap ) ( error ) {
gql_thread , ok := states [ node . ID ( ) ] . ( LockableState )
owner = node . Owner ( )
if ok == false {
return fmt . Errorf ( "Failed to cast state to LockableState" )
}
owner = gql_thread . Owner ( )
return nil
return nil
} )
} )
@ -392,7 +364,7 @@ func GQLTypeGQLThread() * graphql.Object {
gql_type_gql_thread = graphql . NewObject ( graphql . ObjectConfig {
gql_type_gql_thread = graphql . NewObject ( graphql . ObjectConfig {
Name : "GQLThread" ,
Name : "GQLThread" ,
Interfaces : [ ] * graphql . Interface {
Interfaces : [ ] * graphql . Interface {
GQLInterface Graph Node( ) ,
GQLInterface Node( ) ,
GQLInterfaceThread ( ) ,
GQLInterfaceThread ( ) ,
GQLInterfaceLockable ( ) ,
GQLInterfaceLockable ( ) ,
} ,
} ,
@ -410,7 +382,7 @@ func GQLTypeGQLThread() * graphql.Object {
gql_type_gql_thread . AddFieldConfig ( "Name" , & graphql . Field {
gql_type_gql_thread . AddFieldConfig ( "Name" , & graphql . Field {
Type : graphql . String ,
Type : graphql . String ,
Resolve : GQL Nod eName,
Resolve : GQL Lockabl eName,
} )
} )
gql_type_gql_thread . AddFieldConfig ( "Children" , & graphql . Field {
gql_type_gql_thread . AddFieldConfig ( "Children" , & graphql . Field {
@ -452,12 +424,12 @@ func GQLTypeBaseThread() * graphql.Object {
gql_type_base_thread = graphql . NewObject ( graphql . ObjectConfig {
gql_type_base_thread = graphql . NewObject ( graphql . ObjectConfig {
Name : "BaseThread" ,
Name : "BaseThread" ,
Interfaces : [ ] * graphql . Interface {
Interfaces : [ ] * graphql . Interface {
GQLInterface Graph Node( ) ,
GQLInterface Node( ) ,
GQLInterfaceThread ( ) ,
GQLInterfaceThread ( ) ,
GQLInterfaceLockable ( ) ,
GQLInterfaceLockable ( ) ,
} ,
} ,
IsTypeOf : func ( p graphql . IsTypeOfParams ) bool {
IsTypeOf : func ( p graphql . IsTypeOfParams ) bool {
ctx , ok := p . Context . Value ( "graph_context" ) . ( * Graph Context)
ctx , ok := p . Context . Value ( "graph_context" ) . ( * Context)
if ok == false {
if ok == false {
return false
return false
}
}
@ -481,7 +453,7 @@ func GQLTypeBaseThread() * graphql.Object {
gql_type_base_thread . AddFieldConfig ( "Name" , & graphql . Field {
gql_type_base_thread . AddFieldConfig ( "Name" , & graphql . Field {
Type : graphql . String ,
Type : graphql . String ,
Resolve : GQL Nod eName,
Resolve : GQL Lockabl eName,
} )
} )
gql_type_base_thread . AddFieldConfig ( "Children" , & graphql . Field {
gql_type_base_thread . AddFieldConfig ( "Children" , & graphql . Field {
@ -518,11 +490,11 @@ func GQLTypeBaseLockable() * graphql.Object {
gql_type_base_lockable = graphql . NewObject ( graphql . ObjectConfig {
gql_type_base_lockable = graphql . NewObject ( graphql . ObjectConfig {
Name : "BaseLockable" ,
Name : "BaseLockable" ,
Interfaces : [ ] * graphql . Interface {
Interfaces : [ ] * graphql . Interface {
GQLInterface Graph Node( ) ,
GQLInterface Node( ) ,
GQLInterfaceLockable ( ) ,
GQLInterfaceLockable ( ) ,
} ,
} ,
IsTypeOf : func ( p graphql . IsTypeOfParams ) bool {
IsTypeOf : func ( p graphql . IsTypeOfParams ) bool {
ctx , ok := p . Context . Value ( "graph_context" ) . ( * Graph Context)
ctx , ok := p . Context . Value ( "graph_context" ) . ( * Context)
if ok == false {
if ok == false {
return false
return false
}
}
@ -546,7 +518,7 @@ func GQLTypeBaseLockable() * graphql.Object {
gql_type_base_lockable . AddFieldConfig ( "Name" , & graphql . Field {
gql_type_base_lockable . AddFieldConfig ( "Name" , & graphql . Field {
Type : graphql . String ,
Type : graphql . String ,
Resolve : GQL Nod eName,
Resolve : GQL Lockabl eName,
} )
} )
gql_type_base_lockable . AddFieldConfig ( "Requirements" , & graphql . Field {
gql_type_base_lockable . AddFieldConfig ( "Requirements" , & graphql . Field {
@ -573,10 +545,10 @@ func GQLTypeBaseNode() * graphql.Object {
gql_type_base_node = graphql . NewObject ( graphql . ObjectConfig {
gql_type_base_node = graphql . NewObject ( graphql . ObjectConfig {
Name : "BaseNode" ,
Name : "BaseNode" ,
Interfaces : [ ] * graphql . Interface {
Interfaces : [ ] * graphql . Interface {
GQLInterface Graph Node( ) ,
GQLInterface Node( ) ,
} ,
} ,
IsTypeOf : func ( p graphql . IsTypeOfParams ) bool {
IsTypeOf : func ( p graphql . IsTypeOfParams ) bool {
ctx , ok := p . Context . Value ( "graph_context" ) . ( * Graph Context)
ctx , ok := p . Context . Value ( "graph_context" ) . ( * Context)
if ok == false {
if ok == false {
return false
return false
}
}
@ -600,7 +572,7 @@ func GQLTypeBaseNode() * graphql.Object {
gql_type_base_node . AddFieldConfig ( "Name" , & graphql . Field {
gql_type_base_node . AddFieldConfig ( "Name" , & graphql . Field {
Type : graphql . String ,
Type : graphql . String ,
Resolve : GQL Nod eName,
Resolve : GQL Lockabl eName,
} )
} )
}
}
@ -699,32 +671,32 @@ func GQLTypeSignalInput() *graphql.InputObject {
}
}
func GQLSubscribeSignal ( p graphql . ResolveParams ) ( interface { } , error ) {
func GQLSubscribeSignal ( p graphql . ResolveParams ) ( interface { } , error ) {
return GQLSubscribeFn ( p , false , func ( ctx * Graph Context, server * GQLThread , signal GraphSignal , p graphql . ResolveParams ) ( interface { } , error ) {
return GQLSubscribeFn ( p , false , func ( ctx * Context, server * GQLThread , signal GraphSignal , p graphql . ResolveParams ) ( interface { } , error ) {
return signal , nil
return signal , nil
} )
} )
}
}
func GQLSubscribeSelf ( p graphql . ResolveParams ) ( interface { } , error ) {
func GQLSubscribeSelf ( p graphql . ResolveParams ) ( interface { } , error ) {
return GQLSubscribeFn ( p , true , func ( ctx * Graph Context, server * GQLThread , signal GraphSignal , p graphql . ResolveParams ) ( interface { } , error ) {
return GQLSubscribeFn ( p , true , func ( ctx * Context, server * GQLThread , signal GraphSignal , p graphql . ResolveParams ) ( interface { } , error ) {
return server , nil
return server , nil
} )
} )
}
}
func GQLSubscribeFn ( p graphql . ResolveParams , send_nil bool , fn func ( * Graph Context, * GQLThread , GraphSignal , graphql . ResolveParams ) ( interface { } , error ) ) ( interface { } , error ) {
func GQLSubscribeFn ( p graphql . ResolveParams , send_nil bool , fn func ( * Context, * GQLThread , GraphSignal , graphql . ResolveParams ) ( interface { } , error ) ) ( interface { } , error ) {
server , ok := p . Context . Value ( "gql_server" ) . ( * GQLThread )
server , ok := p . Context . Value ( "gql_server" ) . ( * GQLThread )
if ok == false {
if ok == false {
return nil , fmt . Errorf ( "Failed to get gql_server from context and cast to GQLServer" )
return nil , fmt . Errorf ( "Failed to get gql_server from context and cast to GQLServer" )
}
}
ctx , ok := p . Context . Value ( "graph_context" ) . ( * Graph Context)
ctx , ok := p . Context . Value ( "graph_context" ) . ( * Context)
if ok == false {
if ok == false {
return nil , fmt . Errorf ( "Failed to get graph_context from context and cast to Graph Context")
return nil , fmt . Errorf ( "Failed to get graph_context from context and cast to Context")
}
}
c := make ( chan interface { } )
c := make ( chan interface { } )
go func ( c chan interface { } , server * GQLThread ) {
go func ( c chan interface { } , server * GQLThread ) {
ctx . Log . Logf ( "gqlws" , "GQL_SUBSCRIBE_THREAD_START" )
ctx . Log . Logf ( "gqlws" , "GQL_SUBSCRIBE_THREAD_START" )
sig_c := server . UpdateChannel ( 1 )
sig_c := UpdateChannel ( server , 1 , RandID ( ) )
if send_nil == true {
if send_nil == true {
sig_c <- nil
sig_c <- nil
}
}
@ -793,9 +765,9 @@ func GQLMutationSendUpdate() *graphql.Field {
return nil , fmt . Errorf ( "Failed to cast context gql_server to GQLServer: %+v" , p . Context . Value ( "gql_server" ) )
return nil , fmt . Errorf ( "Failed to cast context gql_server to GQLServer: %+v" , p . Context . Value ( "gql_server" ) )
}
}
ctx , ok := p . Context . Value ( "graph_context" ) . ( * Graph Context)
ctx , ok := p . Context . Value ( "graph_context" ) . ( * Context)
if ok == false {
if ok == false {
return nil , fmt . Errorf ( "Failed to cast context graph_context to Graph Context: %+v", p . Context . Value ( "graph_context" ) )
return nil , fmt . Errorf ( "Failed to cast context graph_context to Context: %+v", p . Context . Value ( "graph_context" ) )
}
}
signal_map , ok := p . Args [ "signal" ] . ( map [ string ] interface { } )
signal_map , ok := p . Args [ "signal" ] . ( map [ string ] interface { } )
@ -818,13 +790,13 @@ func GQLMutationSendUpdate() *graphql.Field {
return nil , fmt . Errorf ( "Failed to cast arg id to string" )
return nil , fmt . Errorf ( "Failed to cast arg id to string" )
}
}
var node Graph Node = nil
var node Node = nil
err := UseStates ( ctx , [ ] Graph Node{ server } , func ( states NodeStat eMap) ( error ) {
err := UseStates ( ctx , [ ] Node{ server } , func ( nodes Nod eMap) ( error ) {
node = FindChild ( ctx , server , NodeID ( id ) , stat es)
node = FindChild ( ctx , server , NodeID ( id ) , nod es)
if node == nil {
if node == nil {
return fmt . Errorf ( "Failed to find ID: %s as child of server thread" , id )
return fmt . Errorf ( "Failed to find ID: %s as child of server thread" , id )
}
}
SendUpdate ( ctx , node , signal , stat es)
node . Signal ( ctx , signal , nod es)
return nil
return nil
} )
} )
if err != nil {
if err != nil {