Documentation ¶
Overview ¶
Package redispb marshals and unmarshals Open Match Backend protobuf messages ('MatchObject') 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.
Copyright 2018 Google LLC ¶
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.
Package redispb marshals and unmarshals Open Match Frontend protobuf messages ('Players' or groups) 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.
Copyright 2018 Google LLC ¶
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.
Package redispb marshals and unmarshals Open Match Backend protobuf messages ('MatchObject') 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.
Copyright 2018 Google LLC ¶
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 ¶
- func MarshalToRedis(ctx context.Context, pool *redis.Pool, pb proto.Message, ttl int) error
- func PlayerWatcher(ctx context.Context, pool *redis.Pool, pb om_messages.Player) <-chan om_messages.Player
- func UnmarshalFromRedis(ctx context.Context, pool *redis.Pool, pb *om_messages.MatchObject) error
- func UnmarshalPlayerFromRedis(ctx context.Context, pool *redis.Pool, player *om_messages.Player) error
- func Watcher(ctx context.Context, pool *redis.Pool, pb om_messages.MatchObject) <-chan om_messages.MatchObject
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MarshalToRedis ¶
MarshalToRedis marshals a protobuf message to a redis hash. The protobuf message in question must have an 'id' field. If a positive integer TTL is provided, it will also be set.
func PlayerWatcher ¶
func PlayerWatcher(ctx context.Context, pool *redis.Pool, pb om_messages.Player) <-chan om_messages.Player
PlayerWatcher 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
NOTE: this function will never stop querying Redis during normal operation! You need to
disconnect the client from the frontend API (which closes the context) once you've received the results you were waiting for to stop doing work!
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 UnmarshalPlayerFromRedis ¶
func UnmarshalPlayerFromRedis(ctx context.Context, pool *redis.Pool, player *om_messages.Player) error
UnmarshalPlayerFromRedis unmarshals a Player from a redis hash. This can probably be deprecated if we work on getting the above generic enough. The problem is that protobuf message reflection is pretty messy.
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.