This content originally appeared on DEV Community and was authored by Jin Lee
In part 2 we added redis to our application.
In part 3 we are going to explore the object store interface that pebl provides by incorporating it into our application.
Pebl's Object Store Interface
Object stores like S3 have become essential to cloud workloads. They provide massive scalability and a simplified storage model in which an object is the core building block. However utilizing them can be quite complicated, as we need to learn the intricate implementation details of the underlying system.
With pebl we provide the object store as a pseudo filesystem. This means that you access the remote files as if they were on a local filesystem with pebl.open
. This gives you access to object store capabilities with the intuitive notion of files:
import pebl
with open("local_file", "w") as f:
f.write(b"hello!\n")
with pebl.open("cloud_file", "w") as f:
f.write(b"world!\n")
In a similar fashion, accessing an object is done as a read operation:
import pebl
with pebl.open("cloud_file", "r") as f:
data = f.read(7).decode()
print(data)
Simple Example
The key benefit of this interface is that you can easily interlace object store operations anywhere in your code. So try extending the Flask example we've been working with to utilize the object store. Perhaps you can try creating logs for each request and response pair using Flask's after request handler, or maybe you can try managing user uploaded content such as profile images.
Next in Part 4
In part 4 we will cover how to use scheduled tasks.
This content originally appeared on DEV Community and was authored by Jin Lee
Jin Lee | Sciencx (2023-05-04T19:18:17+00:00) Modern Cloud Workflow with Pebl – Part 3. Retrieved from https://www.scien.cx/2023/05/04/modern-cloud-workflow-with-pebl-part-3/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.