I'm just kinda curious if there is a way to use the mocker driver alongside or instead of the docker one? How does fn even decide which one to use if there is more than one? The reason would be that if it's possible I might try to implement another real driver for another container engine. So far I managed mocker to show up as a driver but still haven't found out how to get fn to use that instead of docker.
There is an example for building an fn with extensions located here: https://github.com/fnproject/fn/blob/master/examples/extensions/main.go#L16 -- for building with a custom driver, at the moment it requires using that same process (i.e. there's no way to configure another driver at runtime from fn core's binary without extending it).
In order to build with an alternative driver such as mocker, a user would use the agent.WithDockerDriver
option to specify a driver when creating the agent, documented here https://godoc.org/github.com/fnproject/fn/api/agent#AgentOption and sample follows:
func main() {
mocker := mock.New()
// configure logstore, mq
da := agent.NewDirectCallDataAccess(logstore, mq)
magent := agent.New(da, agent.WithDockerDriver(mocker))
fns := server.New(server.WithAgent(magent), /*other options*/)
fns.Start(context.Background())
}
we need to tidy up the agent interface to make them easier to create (data access stuff is convoluted), but is not too bad. most of this can be stolen from this file https://github.com/fnproject/fn/blob/master/api/server/server.go -- we need to name it to WithDriver as well :)
assuming you're looking at using something like rkt or a more robust driver on the backend, it's possible to hook this up by implementing the driver interface and in the past we have tried it but we are not maintaining it at present since it was not a viable option (performance issues, perhaps improved since). would be cool to see if you manage to get rkt working, gladly take a PR for it and figure out where to put it :)