Skip to content
This repository has been archived by the owner on Jan 10, 2024. It is now read-only.

chore:basic grpc infra #1619

Merged
merged 6 commits into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -198,20 +198,20 @@ dependencies {
testImplementation 'org.robolectric:robolectric:4.10.3'

// gRPC backend
implementation 'io.grpc:grpc-okhttp:1.43.2' // CURRENT_GRPC_VERSION
implementation 'io.grpc:grpc-protobuf-lite:1.43.2' // CURRENT_GRPC_VERSION
implementation 'io.grpc:grpc-stub:1.43.2' // CURRENT_GRPC_VERSION
implementation 'io.grpc:grpc-okhttp:1.58.0' // CURRENT_GRPC_VERSION
implementation 'io.grpc:grpc-protobuf-lite:1.58.0' // CURRENT_GRPC_VERSION
implementation 'io.grpc:grpc-stub:1.58.0' // CURRENT_GRPC_VERSION
implementation 'org.apache.tomcat:annotations-api:6.0.53'

// View binding helper
implementation "com.github.Zhuinden:fragmentviewbindingdelegate-kt:1.0.0"
}

protobuf {
protoc { artifact = 'com.google.protobuf:protoc:3.19.2' }
protoc { artifact = 'com.google.protobuf:protoc:3.24.3' }
plugins {
javalite { artifact = "com.google.protobuf:protoc-gen-javalite:3.0.0" }
grpc { artifact = 'io.grpc:protoc-gen-grpc-java:1.43.2' } // CURRENT_GRPC_VERSION
grpc { artifact = 'io.grpc:protoc-gen-grpc-java:1.58.0' } // CURRENT_GRPC_VERSION
}
generateProtoTasks {
all().each { task ->
Expand All @@ -220,7 +220,8 @@ protobuf {
}
task.plugins {
grpc { // Options added to --grpc_out
option 'lite' }
option 'lite'
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package de.tum.`in`.tumcampusapp.api.app
import app.tum.campus.api.CampusGrpc
import app.tum.campus.api.GetNewsSourcesRequest
import app.tum.campus.api.GetUpdateNoteRequest
import de.tum.`in`.tumcampusapp.BuildConfig
import de.tum.`in`.tumcampusapp.api.backend.CampusGrpc
import de.tum.`in`.tumcampusapp.api.backend.GetNewsSourcesRequest
import de.tum.`in`.tumcampusapp.api.backend.GetUpdateNoteRequest
import de.tum.`in`.tumcampusapp.component.ui.news.model.NewsSources
import de.tum.`in`.tumcampusapp.component.ui.updatenote.model.UpdateNote
import io.grpc.ManagedChannelBuilder
Expand All @@ -13,7 +13,7 @@ class BackendClient private constructor() {
private var stub: CampusGrpc.CampusFutureStub

init {
val managedChannel = ManagedChannelBuilder.forAddress("api-grpc.tum.app", 443).build()
val managedChannel = ManagedChannelBuilder.forAddress("api.tum.app", 443).build()
stub = CampusGrpc.newFutureStub(managedChannel).withInterceptors(MetadataUtils.newAttachHeadersInterceptor(getHeaderMetaData()))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package de.tum.`in`.tumcampusapp.component.ui.news.model
import androidx.room.Entity
import androidx.room.PrimaryKey
import androidx.room.RoomWarnings
import app.tum.campus.api.GetNewsSourcesReply
import com.google.gson.annotations.SerializedName
import de.tum.`in`.tumcampusapp.api.backend.GetNewsSourcesReply

/**
* This class contains information about the source of a [News] item.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package de.tum.`in`.tumcampusapp.component.ui.updatenote.model

import de.tum.`in`.tumcampusapp.api.backend.GetUpdateNoteReply
import app.tum.campus.api.GetUpdateNoteReply

data class UpdateNote(var updateNote: String) {
companion object {
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/java/de/tum/in/tumcampusapp/utils/Extensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import com.squareup.picasso.RequestCreator
import de.tum.`in`.tumcampusapp.component.other.generic.drawer.NavItem
import io.reactivex.disposables.CompositeDisposable
import io.reactivex.disposables.Disposable
import org.joda.time.DateTime

/**
* Executes the block and return null in case of an [Exception].
Expand Down Expand Up @@ -180,3 +181,8 @@ inline fun <reified T : ViewGroup.LayoutParams> View.layoutParams(block: T.() ->

fun View.dpToPx(dp: Float): Int = context.dpToPx(dp)
fun Context.dpToPx(dp: Float): Int = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, resources.displayMetrics).toInt()

fun com.google.protobuf.Timestamp.toDateTime(): DateTime {
val timeMilis = this.seconds * 1000L + this.nanos / 1000000L
return DateTime(timeMilis)
}
36 changes: 0 additions & 36 deletions app/src/main/proto/backend.proto

This file was deleted.

31 changes: 31 additions & 0 deletions app/src/main/proto/google/api/annotations.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright 2015 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.

syntax = "proto3";

package google.api;

import "google/api/http.proto";
import "google/protobuf/descriptor.proto";

option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations";
option java_multiple_files = true;
option java_outer_classname = "AnnotationsProto";
option java_package = "com.google.api";
option objc_class_prefix = "GAPI";

extend google.protobuf.MethodOptions {
// See `HttpRule`.
HttpRule http = 72295728;
}
Loading