dapr

package module
v0.0.0-...-d5004df Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 6, 2022 License: Apache-2.0 Imports: 8 Imported by: 2

README

Dapr components go SDK POC

This repository is a POC of a SDK for Dapr gRPC Components (a.k.a pluggable components)

Running examples

Start by running ./run.sh inside /examples folder. It will start the daprd runtime with pluggable components version + default in memory state store implementation from components-contrib, use ./run.sh redis to run redis instead.

Run ARGS=--no-cache ./run.sh if you want to rebuild the docker image.

See it working:

curl -X POST -H "Content-Type: application/json" -d '[{ "key": "name", "value": "Bruce Wayne", "metadata": { "ttlInSeconds": "60"}}]' http://localhost:3500/v1.0/state/default
curl http://localhost:3500/v1.0/state/default/name

Implementing a Pluggable State Store component

To create your own implementation:

  1. Create a new folder under /examples
  2. Implement a stateStore using the sdk
  3. create a component.yml (copying from other sources and changing the component-specific metadata)
  4. Run ./run.sh your_folder_goes_here

This will build your component and bootstrap the dapr runtime with the default options.

Getting started

Creating a new component is nothing more than implement a StateStore interface and Run the dapr component server.

package main

import (
	dapr "github.com/mcandeia/dapr-components-go-sdk"
)

func main() {
	dapr.MustRun(dapr.UseStateStore(MyComponentGoesHere{}))
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoneComponentsFound = errors.New("at least one component service should be defined")
)
View Source
var ErrSocketNotDefined = errors.New("socket env `DAPR_COMPONENT_SOCKET_PATH` must be set")

Functions

func MustRun

func MustRun(opts ...Option)

MustRun same as run but panics on error

func Run

func Run(opts ...Option) error

Run starts the component server with the given options.

Types

type Option

type Option = func(*componentOpts)

func UseStateStore

func UseStateStore(stateStore state.Store) Option

UseStateStore sets the component state store implementation.

Directories

Path Synopsis
examples
memory Module
redis Module
state
v1

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL