Coder Social home page Coder Social logo

No examples for streaming about oci-python-sdk HOT 3 CLOSED

oracle avatar oracle commented on July 18, 2024
No examples for streaming

from oci-python-sdk.

Comments (3)

jodoglevy avatar jodoglevy commented on July 18, 2024

Thanks for reporting, we'll be working on this shortly.

from oci-python-sdk.

rosalexander avatar rosalexander commented on July 18, 2024

Hey @luigisaetta,

I played with the streaming service a while ago. Maybe this could help you get started?

import os
import oci
import json
from base64 import b64decode, b64encode

def send_msg():

    stream_id = 'ENTER STREAM OCID HERE'
    config = oci.config.from_file()

    #Create stream client
    stream_client = oci.streaming.StreamClient(config)
    #Create Message Entry Details
    msg_entry = oci.streaming.models.PutMessagesDetailsEntry()
    msg_entry.value = b64encode(bytes('Hello word!', 'utf-8')).decode('utf-8')

    #Create Message Entry
    msgs = oci.streaming.models.PutMessagesDetails()
    msgs.messages = [msg_entry]

    #Put messages
    stream_client.put_messages(stream_id, msgs)


def get_msgs():
    #Create cursor to retrieve messages
    cursor_details = oci.streaming.models.CreateCursorDetails()
    cursor_details.partition = "0"
    cursor_details.type = "TRIM_HORIZON"
    cursor = stream_client.create_cursor(stream_id, cursor_details)
    r = stream_client.get_messages(stream_id, cursor.data.value)

    msgs = []
    if len(r.data):
        for msg in r.data:
            msgs.append(b64decode(msg.value).decode('utf-8'))
    
    return msgs

from oci-python-sdk.

jyotisaini avatar jyotisaini commented on July 18, 2024

Hi , we have added an example to show how to use Streaming service from the SDK. It is available here https://github.com/oracle/oci-python-sdk/blob/master/examples/stream_example.py
closing the issue.

from oci-python-sdk.

Related Issues (20)

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.