Skip to content
This repository has been archived by the owner on Aug 9, 2020. It is now read-only.

add setBucket method #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

thominj
Copy link

@thominj thominj commented Dec 16, 2015

I am using this adapter in a system that works with multiple S3 buckets. We have design constraints that make it difficult to instance a new one each time we switch buckets. This change lets us modify the bucket on the fly, using the same adapter.

@frankdejonge
Copy link
Member

@thominj could you elaborate on the design constraint? It feels like needing this is kind of dirty.

@thominj
Copy link
Author

thominj commented Dec 16, 2015

Sure - essentially we have a service manager that contains a file service
which uses flysystem. We pass the service down through a controller to
maintain inversion of control. So the controller requests the service from
the service manager, then uses it to do "stuff." Part of that "stuff" is
accessing files in different buckets, so we need the S3 adapter to be
configured for different buckets at run time. We could instance a new
flysystem file system and adapter at that point (within the service), but
it would mean that our file service would have to access infrastructure
stuff like config files, and it would also break inversion of control,
because now there would be no good way to tell the service which adapter to
use - the service would have to instance its own adapters and filesystem at
run time.

I realize that including a setter when we already set the bucket in the
constructor is not a great solution, but I think that what we are running
into here is an underlying assumption that you would only ever need one
bucket per adapter. We are finding that in practice, we often need access
to several different buckets. This is the easiest way I could think of to
provide that option, without breaking backwards compatibility.

On Wed, Dec 16, 2015 at 3:03 PM, Frank de Jonge [email protected]
wrote:

@thominj https://github.com/thominj could you elaborate on the design
constraint? It feels like needing this is kind of dirty.


Reply to this email directly or view it on GitHub
#14 (comment)
.

@frankdejonge
Copy link
Member

@thominj which framework are you using?

@thominj
Copy link
Author

thominj commented Dec 17, 2015

We are using this in a couple of different systems, which use ZF1 (legacy system), ZF2, and Slim.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants