#introspect/discover the module call chain?

1 messages · Page 1 of 1 (latest)

undone fiber
#

For example: dagger call -m TheModule function-a --option=foo function-b --more-options=bar is it possible for function-a to know that function-b is also being invoked as part of the call chain/query?

spark mirage
#

nope, each function is independent!

#

it makes a bit more sense if you think of it in terms of changing functions like in a programming languages - it's like FunctionA(foo).FunctionB(bar)

#

you have to evaluate them in order

#

what's the use case, out of curiosity, there might be an easier way to do what you're looking to do

undone fiber
#

Ah OK-- a blessing and a curse. I'm trying to find a way to require certain functions or arguments within the call chain based upon what the previous functions had returned. The specific case is where a state (file) might be generated by a function. If the file is generated, it should then be exported-- otherwise it would be lost.

#

(I'm trying to avoid writing the state file into a cache volume)

limpid thicket
# undone fiber Ah OK-- a blessing and a curse. I'm trying to find a way to require certain fun...

can't this be resolved by custom types?

i.e: FunctionA returns some type with a state file field. Then, functionB can be a function of that same type which checks if the inner state is set or not.

i.e:

package main

import (
    "context"
    "dagger/state/internal/dagger"
)

type State struct{}

type SomeType struct {
    State *dagger.File
}

func (m *SomeType) FunctionB() {
    if m.State != nil {
        // do whatever you need with the state file
    }
}

// Returns lines that match a pattern in the files of the provided Directory
func (m *State) FunctionA() SomeType {
    return SomeType{}
}