Documentation
¶
Overview ¶
Copyright 2024 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
http://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.
Copyright 2024 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
http://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.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // Metric variable declarations are global to the module, so they can be // accessed directly in the module code. // The live counters that the metrics observe. TicketCount int64 InactiveCount int64 AssignmentCount int64 )
Functions ¶
func RegisterMetrics ¶
func RegisterMetrics(meterPointer *otelmetrics.Meter)
Types ¶
type ReplicatedTicketCache ¶
type ReplicatedTicketCache struct { // Local copies of all the state data. Tickets sync.Map InactiveSet sync.Map Assignments sync.Map // How this replicatedTicketCache is replicated. Replicator store.StateReplicator // The queue of cache updates UpRequests chan *UpdateRequest // IdValidator *regexp.Regexp // Application config Cfg *viper.Viper }
The server instantiates a replicatedTicketCache on startup, and all ticket-reading functionality reads from this local cache. The cache also has the necessary data structures for replicating ticket cache changes that come in to this instance by it handling gRPC calls. This data structure contains sync.Map members, so it should not be copied after instantiation (see https://pkg.go.dev/sync#Map)
func (*ReplicatedTicketCache) IncomingReplicationQueue ¶
func (tc *ReplicatedTicketCache) IncomingReplicationQueue(ctx context.Context)
incomingReplicationQueue is an asynchronous goroutine that runs for the lifetime of the server. It reads all incoming replication events from the configured state storage and applies them to the local ticket cache. In practice, this does almost all the work for every om-core gRPC handler /except/ InvokeMatchMakingFunction.
func (*ReplicatedTicketCache) OutgoingReplicationQueue ¶
func (tc *ReplicatedTicketCache) OutgoingReplicationQueue(ctx context.Context)
outgoingReplicationQueue is an asynchronous goroutine that runs for the lifetime of the server. It processes incoming repliation events that are produced by gRPC handlers, and sends those events to the configured state storage. The updates aren't applied to the local copy of the ticket cache yet at this point; once the event has been successfully replicated and received in the incomingReplicationQueue goroutine, the update is applied to the local cache.
type UpdateRequest ¶
type UpdateRequest struct { Ctx context.Context // The update itself. Update store.StateUpdate // Return channel to confirm the write by sending back the assigned ticket ID ResultsChan chan *store.StateResponse }
cache.UpdateRequest is basically a wrapper around a StateUpdate (in statestorage/datatypes/store.go) that adds context and a channel where results should go. The state storage layer shouldn't need to understand the underlying context, or where the update request originated (which is where it will return). These are necessary for the gRPC server in om-core, however!