Git Product home page Git Product logo

fauna-go's People

Contributors

adambollen avatar breathe avatar clbray avatar cleve-fauna avatar cynicaljoy avatar dependabot[bot] avatar erickpintor avatar jrodewig avatar pnwpedro avatar sprsquish avatar tysont avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

fauna-go's Issues

not sure if I can replicate `ReadIdleTimeout` in python

I'm not completely sure if I can replicate ReadIdleTimeout in the python driver ...

fauna-go/client.go

Lines 90 to 103 in 2784d07

readIdleTimeout := DefaultHttpReadIdleTimeout
if val, found := os.LookupEnv(EnvFaunaTimeout); found {
timeoutFromEnv, err := time.ParseDuration(val)
if err != nil {
_, _ = fmt.Fprintf(os.Stderr, "failed to parse timeout, using default\n")
} else {
if timeoutFromEnv.Seconds() <= 0 {
_, _ = fmt.Fprintf(os.Stderr, "timeout must be greater than 0, using default\n")
} else {
readIdleTimeout = timeoutFromEnv
}
}
}

As I understand it -- the above uses http2 ping frames to implement a health-check for a connection, which serves to both keep the connection alive across things like load balancers which require traffic flow, and also to detect when a connection is down (which, without read/write timeout, would otherwise potentially just block forever).

I asked this question on the httpx repo to see if maybe there's a way to support a similar behavior as golang provides here as the golang behavior definitely seems like the most ideal behavior ...

But -- especially if we can't duplicate this in other drivers - I sort of think we should rename this env var to be a little more informative as to its meaning ...

FQL Query string interpolation

I'm trying to sort out a good UX for creating a query, what do people think about:

var addr string
...
client.Query(FQL(`IndexedRead.byAddress(${address}) { name: .data.name }`, QueryArgs(Arugment("address", addr)))

This would change the Query method contract from:

type QueryArgs map[string]interface{}

func (c *Client) Query(fql string, args QueryArgs, obj interface{}, opts ...QueryOptFn) (*Response, error)

to:

func (c *Client) Query(query FQLQuery, obj interface{}, opts ...QueryOptFn) (*Response, error)

func FQL(input string, args QueryArg) FQLQuery

we'd parse the string for all ${vars} and iterate through all of the QueryArg and if any are missing we'd return an error. I like wrapping in ${} as it makes it a bit easier to read, it's easier to parse out (we can actually use os.Expand almost turnkey) and it's inline with the current proposal for adding string interpolation the language. Though, that's also a con IMO...feels like we'd eventually be trampling on std lib in a bit of a weird way, but that proposal might never be accepted so probably best to sort it out if it ever becomes an issue if we're otherwise happy with that pattern.

I'm not loving the naming though...maybe something like:

func (c *Client) Do(query QueryInput, obj interface{}, opts ...QueryOptFn) (*Response, error)

func Query(query string, args QueryArgs) QueryInput

I feel like Do is a little more idiomatic Go (see: http.Client.Do) and we avoid Query(<query>) or using the language acronym as a struct type.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.