You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: master_grpc_server.go
    path of file: ./repos/gleam/distributed/master
    
    the code of the file until where you have to start completion: package master

import (
	"fmt"
	"io"
	"io/ioutil"
	"log"
	"os"
	"path/filepath"
	"strings"
	"time"

	"context"
	"github.com/chrislusf/gleam/pb"
	"github.com/golang/protobuf/proto"
	"github.com/hashicorp/golang-lru"
)

type MasterServer struct {
	Topology     *Topology
	statusCache  *lru.Cache
	logDirectory string
	startTime    time.Time
}

func newMasterServer(logDirectory string) *MasterServer {
	m := &Mas
    
func (s *MasterServer) SendHeartbeat(stream pb.GleamMaster_SendHeartbeatServer) error {
	var location *pb.Location
	for {
		heartbeat, err := stream.Recv()
		if err == nil {
			if location == nil {
				location = heartbeat.Location
				log.Printf("added agent: %v", location)
			}
		} else {
			if location != nil {
				s.Topology.deleteAgentInformation(location)
			}
			log.Printf("lost agent: %v", location)

			if err == io.EOF {
				return nil
			}
			if err != nil {
				return err
			}
		}
		s.Topology.UpdateAgentInformation(heartbeat)
	}
}