-
-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add NewServerWithBucket and NewServerWithFS methods #47
Conversation
@bdon Once I get this back in sync with the latest release is this a patch you are interested in? |
@thisisaaronland thanks for checking in - I have been cowardly avoiding anything related to #46 and #20, because other projects have been higher priority, and exposing a developer facing API in this project needs to come after we have a sufficient core of functionality done - I just added
This seems interesting to expose through a programmatic API, but the code that does the embedding needs to live outside of this library - all of the operations in here are intentionally designed to work for any size of archive, up to the planet. It looks like this works by using In general, I do want a more modular API for doing what you said - provide a bucket and let you serve it from an embedded program. I don't want to extend the server too far in functionality, though; I'm working on a Caddy plugin https://github.com/orgs/protomaps/discussions/1 that will accomplish more HTTP and header-ish operations. Finally, I will add a CI task that runs |
* add CI for checking formatting * go fmt [#47]
ad2801a added a GitHub action that fails if the code is not formatted with |
It sounds like the easiest thing to do would be to change the signature of That way the function would simply call Likewise A recent-ish addition to all of this is that google/go-cloud#3272 I am not suggesting that |
Related |
Can you rebase this off main to pick up the formatting changes? If I just split the NewServer function into 2 where you can provide your own bucket, is that sufficient? |
In the course of getting this to work in another branch, I am no longer certain this PR makes much sense. Specifically, this branch: https://github.com/protomaps/go-pmtiles/compare/main...sfomuseum:go-pmtiles:fs-bucket-2?expand=1 Which is used here: https://github.com/sfomuseum/go-sfomuseum-pmtiles/blob/static/cmd/server-static/main.go The problem stems from the use/need for a PMTiles-specific Even if a bundled https://github.com/sfomuseum/go-pmtiles/blob/fs-bucket-2/pmtiles/server.go#L147-L153 I suppose there is still some use to the methods in that it would allow you to bundle small-ish maps inside a Lambda function without the need to configure a separate S3 bucket for the tile data itself (writing the data to the functions /tmp directory and assuming that the function and data will be cached for heavy use). I suppose just having a https://github.com/sfomuseum/go-pmtiles/blob/fs-bucket-2/pmtiles/server.go#L156 Thoughts? |
Why can't you write to your own mem bucket, hold the pointer, and create a pmtiles |
Yes, that works too: https://github.com/sfomuseum/go-sfomuseum-pmtiles/blob/static/bucket.go It does suggest that it would/might be useful to extend that package to implement (wrap) all of the It's also another argument for not including a https://github.com/sfomuseum/go-sfomuseum-pmtiles/blob/static/server.go |
PR has been updated to remove https://github.com/sfomuseum/go-sfomuseum-pmtiles/blob/static/application/server/server.go#L99-L127 https://github.com/sfomuseum/go-sfomuseum-pmtiles/blob/static/bucket/fs.go |
Thanks, do you need me to do a minor release (1.10.1)? |
Yes, please. Thanks, |
v1.10.4 is tagged with new binaries on releases; I also changed the notarization code to the new Apple tool so let me know if there's any issues with the CLI on Mac. |
This PR add two new methods:
NewServerWithBucket
instantiates apmtiles.Server
instance from a pre-existinggocloud.dev/blob.Bucket
instance. Under the hood theNewServer
method has been updated to call this after it has created a bucket from a PMTiles path URI.NewServerWithFS
instantiates a new in-memorygocloud.dev/blob.Bucket
instance and populates it with the contents of afs.FS
instance. Once created it invokes theNewServerWithBucket
method.These changes make it possible to bundle (and use) a PMTiles database as an
embed
-able asset in a Go program. While this probably doesn't make sense for very large databases it can be useful for smaller databases.Additionally, this PR:
go vet