compute-sdk-go icon indicating copy to clipboard operation
compute-sdk-go copied to clipboard

internal: remove package-level init with fastlyABIInit()

Open dgryski opened this issue 2 years ago • 8 comments

We were ignoring the return value anyway and it complicates wizer integration.

dgryski avatar Apr 15 '23 18:04 dgryski

Just need to figure out where to put this for people who want to call it. Maybe at the top-level sdk.go file ?

dgryski avatar Apr 15 '23 18:04 dgryski

What purpose does the call serve? What're the implications of not calling it?

joeshaw avatar Apr 18 '23 16:04 joeshaw

The call allows an app to say "I'm using this version of the ABI" and verify that the wasm runtime supports it. However, it is purely advisory and the return value ("Sounds Good" / "I'm sorry I don't support that version") was ignored anyway.

dgryski avatar Apr 18 '23 16:04 dgryski

What's the right thing to do if we don't support the version? Panic? If so, we could maybe put it into the fsthttp.ServeFunc function since that's going to be the entrypoint for nearly all apps.

joeshaw avatar Apr 19 '23 17:04 joeshaw

What's the right thing to do if we don't support the version? Panic? If so, we could maybe put it into the fsthttp.ServeFunc function since that's going to be the entrypoint for nearly all apps.

I'd possibly also write to stderr so that something appears in fastly log-tail

JakeChampion avatar Apr 19 '23 18:04 JakeChampion

Can we just move this into handle.go:Serve(), before we create the ClientRequest?

fgsch avatar Apr 21 '23 17:04 fgsch

There are code entries that could be called before Serve(), for example loading a configuration or something from a kvstore or equivalent. So while it would be seen, it wouldn't necessarily be the first action the SDK would take with the host.

dgryski avatar May 15 '23 22:05 dgryski

There are code entries that could be called before Serve(), for example loading a configuration or something from a kvstore or equivalent. So while it would be seen, it wouldn't necessarily be the first action the SDK would take with the host.

Ah, yes, you are right. I still think this should happen automatically (and not something the end user should care about) but I'm not sure how to achieve that outside init or adding the extra check in all the possible entrypoints.

fgsch avatar May 16 '23 11:05 fgsch