redispb

package
v0.2.0-alpha-RC1 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2018 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package redispb marshals and unmarshals protobuf messages for redis state storage.

More details about the protobuf messages used in Open Match can be found in the api/protobuf-spec/om_messages.proto file.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

All of this can probably be done more succinctly with some more interface and reflection, this is a hack but works for now.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MarshalToRedis

func MarshalToRedis(ctx context.Context, pb proto.Message, pool *redis.Pool) (err error)

MarshalToRedis marshals a protobuf message to a redis hash. The protobuf message in question must have an 'id' field.

func UnmarshalFromRedis

func UnmarshalFromRedis(ctx context.Context, pool *redis.Pool, pb *om_messages.MatchObject) error

UnmarshalFromRedis unmarshals a MatchObject from a redis hash. This can probably be made generic to work with other pb messages in the future. In every case where we don't get an update, we return an error.

func Watcher

func Watcher(ctx context.Context, pool *redis.Pool, pb om_messages.MatchObject) <-chan om_messages.MatchObject

Watcher makes a channel and returns it immediately. It also launches an asynchronous goroutine that watches a redis key and returns updates to that key on the channel.

The pattern for this function is from 'Go Concurrency Patterns', it is a function that wraps a closure goroutine, and returns a channel. reference: https://talks.golang.org/2012/concurrency.slide#25

Types

This section is empty.

Jump to

Keyboard shortcuts

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